From 63623e14d8a05fda42d600ef0d675fc94b59b762 Mon Sep 17 00:00:00 2001 From: liangshenglin1 Date: Mon, 19 Jul 2021 14:51:56 +0000 Subject: [PATCH] fix rpc bug --- ipc/native/src/core/include/ipc_process_skeleton.h | 2 +- ipc/native/src/core/source/ipc_process_skeleton.cpp | 8 ++++---- ipc/native/src/mock/source/binder_invoker.cpp | 4 ++++ .../src/socket/dbinder_remote_listener.cpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ipc/native/src/core/include/ipc_process_skeleton.h b/ipc/native/src/core/include/ipc_process_skeleton.h index f362f28..dce6cfa 100755 --- a/ipc/native/src/core/include/ipc_process_skeleton.h +++ b/ipc/native/src/core/include/ipc_process_skeleton.h @@ -200,7 +200,7 @@ private: IPCProcessSkeleton(); static IPCProcessSkeleton *instance_; static std::mutex procMutex_; - std::shared_mutex mutex_; + std::recursive_mutex mutex_; std::shared_mutex rawDataMutex_; std::map> objects_; std::map isContainStub_; diff --git a/ipc/native/src/core/source/ipc_process_skeleton.cpp b/ipc/native/src/core/source/ipc_process_skeleton.cpp index ef9a066..c9a72d5 100755 --- a/ipc/native/src/core/source/ipc_process_skeleton.cpp +++ b/ipc/native/src/core/source/ipc_process_skeleton.cpp @@ -126,7 +126,7 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle) IRemoteObject *remoteObject = nullptr; std::u16string descriptor = MakeHandleDescriptor(handle); { - std::unique_lock lockGuard(mutex_); + std::lock_guard lock(mutex_); remoteObject = QueryObjectInner(descriptor); if (remoteObject == nullptr) { @@ -232,7 +232,7 @@ bool IPCProcessSkeleton::IsContainsObject(IRemoteObject *object) bool IPCProcessSkeleton::DetachObject(IRemoteObject *object) { - std::unique_lock lockGuard(mutex_); + std::lock_guard lock(mutex_); // If it fails, clear it in the destructor. (void)isContainStub_.erase(object); @@ -246,7 +246,7 @@ bool IPCProcessSkeleton::DetachObject(IRemoteObject *object) bool IPCProcessSkeleton::AttachObject(IRemoteObject *object) { - std::unique_lock lockGuard(mutex_); + std::lock_guard lock(mutex_); return AttachObjectInner(object); } @@ -269,7 +269,7 @@ IRemoteObject *IPCProcessSkeleton::QueryObject(const std::u16string &descriptor) return nullptr; } - std::shared_lock lockGuard(mutex_); + std::lock_guard lock(mutex_); return QueryObjectInner(descriptor); } diff --git a/ipc/native/src/mock/source/binder_invoker.cpp b/ipc/native/src/mock/source/binder_invoker.cpp index 23c5296..6759f2e 100755 --- a/ipc/native/src/mock/source/binder_invoker.cpp +++ b/ipc/native/src/mock/source/binder_invoker.cpp @@ -249,6 +249,10 @@ int BinderInvoker::TranslateStub(binder_uintptr_t cookie, binder_uintptr_t ptr, sptr BinderInvoker::GetSAMgrObject() { + IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent(); + if (current != nullptr) { + return current->GetRegistryObject(); + } return nullptr; } diff --git a/services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp b/services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp index b9f753a..a4f25e8 100755 --- a/services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp +++ b/services/dbinder/dbinder_service/src/socket/dbinder_remote_listener.cpp @@ -120,7 +120,7 @@ std::shared_ptr DBinderRemoteListener::OpenSoftbusSession(const std::st int DBinderRemoteListener::OnSessionOpened(std::shared_ptr session) { DBINDER_LOGI("peer session is open"); - if (session->GetPeerUid() != getuid() || session->GetPeerSessionName() != PEER_SESSION_NAME) { + if (session->GetPeerSessionName() != PEER_SESSION_NAME) { DBINDER_LOGE("invalid session name, peer session name = %{public}s", session->GetPeerSessionName().c_str()); return -DBINDER_SERVICE_WRONG_SESSION; } -- GitLab