提交 63623e14 编写于 作者: L liangshenglin1 提交者: Gitee

fix rpc bug

上级 2a12dd26
......@@ -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<std::u16string, wptr<IRemoteObject>> objects_;
std::map<IRemoteObject *, bool> isContainStub_;
......
......@@ -126,7 +126,7 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
IRemoteObject *remoteObject = nullptr;
std::u16string descriptor = MakeHandleDescriptor(handle);
{
std::unique_lock<std::shared_mutex> lockGuard(mutex_);
std::lock_guard<std::recursive_mutex> 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<std::shared_mutex> lockGuard(mutex_);
std::lock_guard<std::recursive_mutex> 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<std::shared_mutex> lockGuard(mutex_);
std::lock_guard<std::recursive_mutex> lock(mutex_);
return AttachObjectInner(object);
}
......@@ -269,7 +269,7 @@ IRemoteObject *IPCProcessSkeleton::QueryObject(const std::u16string &descriptor)
return nullptr;
}
std::shared_lock<std::shared_mutex> lockGuard(mutex_);
std::lock_guard<std::recursive_mutex> lock(mutex_);
return QueryObjectInner(descriptor);
}
......
......@@ -249,6 +249,10 @@ int BinderInvoker::TranslateStub(binder_uintptr_t cookie, binder_uintptr_t ptr,
sptr<IRemoteObject> BinderInvoker::GetSAMgrObject()
{
IPCProcessSkeleton *current = IPCProcessSkeleton::GetCurrent();
if (current != nullptr) {
return current->GetRegistryObject();
}
return nullptr;
}
......
......@@ -120,7 +120,7 @@ std::shared_ptr<Session> DBinderRemoteListener::OpenSoftbusSession(const std::st
int DBinderRemoteListener::OnSessionOpened(std::shared_ptr<Session> 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册