From e0abe3a00dee1b630933e4c606c38ae50d19a1b6 Mon Sep 17 00:00:00 2001 From: zhaoshuyuan Date: Wed, 4 Dec 2024 22:07:33 +0800 Subject: [PATCH] =?UTF-8?q?storagedaemon=E6=8E=A5=E5=8F=A3=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E5=8A=A0=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoshuyuan --- .../include/ipc/storage_daemon_stub.h | 1 + .../storage_daemon/ipc/src/storage_daemon_stub.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/services/storage_daemon/include/ipc/storage_daemon_stub.h b/services/storage_daemon/include/ipc/storage_daemon_stub.h index 27f7eb8b..7590c21a 100644 --- a/services/storage_daemon/include/ipc/storage_daemon_stub.h +++ b/services/storage_daemon/include/ipc/storage_daemon_stub.h @@ -86,6 +86,7 @@ private: int32_t HandleMountMediaFuse(MessageParcel &data, MessageParcel &reply); int32_t HandleUMountMediaFuse(MessageParcel &data, MessageParcel &reply); + std::mutex mutex_; }; } // StorageDaemon } // OHOS diff --git a/services/storage_daemon/ipc/src/storage_daemon_stub.cpp b/services/storage_daemon/ipc/src/storage_daemon_stub.cpp index bc5938e0..21a9e577 100644 --- a/services/storage_daemon/ipc/src/storage_daemon_stub.cpp +++ b/services/storage_daemon/ipc/src/storage_daemon_stub.cpp @@ -353,6 +353,7 @@ int32_t StorageDaemonStub::HandleSetVolDesc(MessageParcel &data, MessageParcel & int32_t StorageDaemonStub::HandlePrepareUserDirs(MessageParcel &data, MessageParcel &reply) { + std::lock_guard lock(mutex_); int32_t userId = data.ReadInt32(); uint32_t flags = data.ReadUint32(); @@ -366,6 +367,7 @@ int32_t StorageDaemonStub::HandlePrepareUserDirs(MessageParcel &data, MessagePar int32_t StorageDaemonStub::HandleDestroyUserDirs(MessageParcel &data, MessageParcel &reply) { + std::lock_guard lock(mutex_); int32_t userId = data.ReadInt32(); uint32_t flags = data.ReadUint32(); @@ -415,6 +417,7 @@ int32_t StorageDaemonStub::HandleCompleteAddUser(MessageParcel &data, MessagePar int32_t StorageDaemonStub::HandleInitGlobalKey(MessageParcel &data, MessageParcel &reply) { + std::lock_guard lock(mutex_); int err = InitGlobalKey(); if (!reply.WriteInt32(err)) { return E_WRITE_REPLY_ERR; @@ -425,6 +428,7 @@ int32_t StorageDaemonStub::HandleInitGlobalKey(MessageParcel &data, MessageParce int32_t StorageDaemonStub::HandleInitGlobalUserKeys(MessageParcel &data, MessageParcel &reply) { + std::lock_guard lock(mutex_); int err = InitGlobalUserKeys(); if (!reply.WriteInt32(err)) { return E_WRITE_REPLY_ERR; @@ -473,6 +477,7 @@ int32_t StorageDaemonStub::HandleUpdateUserAuth(MessageParcel &data, MessageParc data.ReadUInt8Vector(&newSecret); int timerId = StorageXCollie::SetTimer("storage:UpdateUserAuth", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = UpdateUserAuth(userId, secureUid, token, oldSecret, newSecret); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -517,6 +522,7 @@ int32_t StorageDaemonStub::HandleActiveUserKey(MessageParcel &data, MessageParce data.ReadUInt8Vector(&secret); int timerId = StorageXCollie::SetTimer("storage:ActiveUserKey", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = ActiveUserKey(userId, token, secret); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -531,6 +537,7 @@ int32_t StorageDaemonStub::HandleInactiveUserKey(MessageParcel &data, MessagePar uint32_t userId = data.ReadUint32(); int timerId = StorageXCollie::SetTimer("storage:InactiveUserKey", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = InactiveUserKey(userId); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -545,6 +552,7 @@ int32_t StorageDaemonStub::HandleLockUserScreen(MessageParcel &data, MessageParc uint32_t userId = data.ReadUint32(); int timerId = StorageXCollie::SetTimer("storage:LockUserScreen", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = LockUserScreen(userId); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -564,6 +572,7 @@ int32_t StorageDaemonStub::HandleUnlockUserScreen(MessageParcel &data, MessagePa data.ReadUInt8Vector(&secret); int timerId = StorageXCollie::SetTimer("storage:UnlockUserScreen", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = UnlockUserScreen(userId, token, secret); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -578,6 +587,7 @@ int32_t StorageDaemonStub::HandleGetLockScreenStatus(MessageParcel &data, Messag uint32_t userId = data.ReadUint32(); bool lockScreenStatus = false; int timerId = StorageXCollie::SetTimer("storage:GetLockScreenStatus", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = GetLockScreenStatus(userId, lockScreenStatus); StorageXCollie::CancelTimer(timerId); if (!reply.WriteBool(lockScreenStatus)) { @@ -596,6 +606,7 @@ int32_t StorageDaemonStub::HandleGenerateAppkey(MessageParcel &data, MessageParc uint32_t hashId = data.ReadUint32(); std::string keyId; int timerId = StorageXCollie::SetTimer("storage:GenerateAppkey", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = GenerateAppkey(userId, hashId, keyId); StorageXCollie::CancelTimer(timerId); if (!reply.WriteString(keyId)) { @@ -613,6 +624,7 @@ int32_t StorageDaemonStub::HandleDeleteAppkey(MessageParcel &data, MessageParcel uint32_t userId = data.ReadUint32(); std::string keyId = data.ReadString(); int timerId = StorageXCollie::SetTimer("storage:DeleteAppkey", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = DeleteAppkey(userId, keyId); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -655,6 +667,7 @@ int32_t StorageDaemonStub::HandleUpdateKeyContext(MessageParcel &data, MessagePa { uint32_t userId = data.ReadUint32(); int timerId = StorageXCollie::SetTimer("storage:UpdateKeyContext", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = UpdateKeyContext(userId); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { @@ -811,6 +824,7 @@ int32_t StorageDaemonStub::HandleGetFileEncryptStatus(MessageParcel &data, Messa bool needCheckDirMount = data.ReadBool(); bool isEncrypted = true; int timerId = StorageXCollie::SetTimer("storage:GetFileEncryptStatus", LOCAL_TIME_OUT_SECONDS); + std::lock_guard lock(mutex_); int err = GetFileEncryptStatus(userId, isEncrypted, needCheckDirMount); StorageXCollie::CancelTimer(timerId); if (!reply.WriteInt32(err)) { -- Gitee