Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
230bd202
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
大约 1 年 前同步成功
通知
20
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
communication_ipc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
230bd202
编写于
8月 20, 2021
作者:
L
liangshenglin1
提交者:
Gitee
8月 20, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dead lock of create proxy
Signed-off-by:
N
liangshenglin
<
liangshenglin1@huawei.com
>
上级
589bde9f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
65 deletion
+33
-65
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
+1
-1
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+14
-49
ipc/native/src/core/source/ipc_process_skeleton.cpp
ipc/native/src/core/source/ipc_process_skeleton.cpp
+16
-13
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
+2
-2
未找到文件。
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
浏览文件 @
230bd202
...
...
@@ -70,7 +70,7 @@ public:
std
::
string
GetDataBusName
();
int
GetProto
()
const
;
void
WaitForInit
();
void
WaitForInit
(
bool
newProxy
);
std
::
u16string
GetInterfaceDescriptor
();
private:
...
...
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
230bd202
...
...
@@ -103,7 +103,6 @@ int IPCObjectProxy::SendRequestInner(bool isLocal, uint32_t code, MessageParcel
std
::
u16string
IPCObjectProxy
::
GetInterfaceDescriptor
()
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
initMutex_
);
if
(
!
remoteDescriptor_
.
empty
())
{
return
remoteDescriptor_
;
}
...
...
@@ -159,34 +158,33 @@ std::string IPCObjectProxy::GetDataBusName()
void
IPCObjectProxy
::
OnFirstStrongRef
(
const
void
*
objectId
)
{
return
WaitForInit
();
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetDefaultInvoker
();
if
(
invoker
!=
nullptr
)
{
invoker
->
AcquireHandle
(
handle_
);
}
}
void
IPCObjectProxy
::
WaitForInit
()
void
IPCObjectProxy
::
WaitForInit
(
bool
newProxy
)
{
#ifndef CONFIG_IPC_SINGLE
int
type
=
0
;
#endif
{
bool
acquire
=
true
;
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
initMutex_
);
if
(
IsObjectDead
())
{
ZLOGI
(
LABEL
,
"check a dead proxy, init again"
);
isRemoteDead_
=
false
;
isFinishInit_
=
false
;
acquire
=
false
;
}
// check again is this object been initialized
if
(
isFinishInit_
)
{
return
;
}
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetDefaultInvoker
();
if
(
invoker
!=
nullptr
&&
acquire
==
true
)
{
invoker
->
AcquireHandle
(
handle_
);
}
#ifndef CONFIG_IPC_SINGLE
if
(
newProxy
==
true
)
{
ReleaseProto
();
}
type
=
UpdateProto
();
#endif
isFinishInit_
=
true
;
...
...
@@ -206,15 +204,15 @@ void IPCObjectProxy::OnLastStrongRef(const void *objectId)
return
;
}
if
(
current
->
DetachObject
(
this
))
{
if
(
current
->
DetachObject
(
this
))
{
// if detach successfully, this proxy will be destroyed
#ifndef CONFIG_IPC_SINGLE
ReleaseProto
();
#endif
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetDefaultInvoker
();
if
(
invoker
!=
nullptr
)
{
invoker
->
ReleaseHandle
(
handle_
);
}
}
#ifndef CONFIG_IPC_SINGLE
ReleaseProto
();
#endif
}
...
...
@@ -412,23 +410,7 @@ void IPCObjectProxy::IncRefToRemote()
void
IPCObjectProxy
::
ReleaseProto
()
{
switch
(
GetProto
())
{
case
IRemoteObject
::
IF_PROT_BINDER
:
{
ZLOGW
(
LABEL
,
"it is normal binder, try to delete handle to index"
);
ReleaseBinderProto
();
break
;
}
case
IRemoteObject
::
IF_PROT_DATABUS
:
{
ReleaseDatabusProto
();
break
;
}
default:
{
ZLOGE
(
LABEL
,
"ReleaseProto Invalid Type"
);
break
;
}
}
return
;
ReleaseDatabusProto
();
}
void
IPCObjectProxy
::
SetProto
(
int
proto
)
...
...
@@ -637,24 +619,7 @@ void IPCObjectProxy::ReleaseDatabusProto()
void
IPCObjectProxy
::
ReleaseBinderProto
()
{
if
(
handle_
==
0
)
{
ZLOGI
(
LABEL
,
"%s:handle == 0, do nothing"
,
__func__
);
return
;
}
if
(
GetProto
()
!=
IRemoteObject
::
IF_PROT_BINDER
)
{
ZLOGI
(
LABEL
,
"not binder proxy, need do nothing"
);
return
;
}
IPCProcessSkeleton
*
current
=
IPCProcessSkeleton
::
GetCurrent
();
if
(
current
==
nullptr
)
{
ZLOGE
(
LABEL
,
"release proto current is null"
);
return
;
}
(
void
)
current
->
DetachHandleToIndex
(
handle_
);
return
;
// do nothing
}
#endif
}
// namespace OHOS
ipc/native/src/core/source/ipc_process_skeleton.cpp
浏览文件 @
230bd202
...
...
@@ -123,6 +123,7 @@ std::u16string IPCProcessSkeleton::MakeHandleDescriptor(int handle)
IRemoteObject
*
IPCProcessSkeleton
::
FindOrNewObject
(
int
handle
)
{
bool
newProxy
=
false
;
IRemoteObject
*
remoteObject
=
nullptr
;
std
::
u16string
descriptor
=
MakeHandleDescriptor
(
handle
);
{
...
...
@@ -142,20 +143,22 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
}
}
remoteObject
=
new
IPCObjectProxy
(
handle
,
descriptor
);
remoteObject
->
AttemptAcquire
(
this
);
newProxy
=
true
;
auto
proxy
=
new
IPCObjectProxy
(
handle
,
descriptor
);
proxy
->
AttemptAcquire
(
this
);
// AttemptAcquire always returns true as life time is extended
remoteObject
=
reinterpret_cast
<
IRemoteObject
*>
(
proxy
);
if
(
!
AttachObjectInner
(
remoteObject
))
{
DBINDER_LOGE
(
"attach object fail"
);
delete
remoteObject
;
DBINDER_LOGE
(
"attach object fail
ed
"
);
delete
proxy
;
return
nullptr
;
}
return
remoteObject
;
}
else
{
remoteObject
->
AttemptAcquire
(
this
);
}
}
IPCObjectProxy
*
remoteProxy
=
reinterpret_cast
<
IPCObjectProxy
*>
(
remoteObject
);
remoteProxy
->
WaitForInit
();
remoteProxy
->
WaitForInit
(
newProxy
);
return
remoteObject
;
}
...
...
@@ -233,9 +236,14 @@ bool IPCProcessSkeleton::IsContainsObject(IRemoteObject *object)
bool
IPCProcessSkeleton
::
DetachObject
(
IRemoteObject
*
object
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex_
);
int
strongRef
=
object
->
GetSptrRefCount
();
if
(
strongRef
>
0
)
{
DBINDER_LOGI
(
"proxy is still strong referenced:%{public}d"
,
strongRef
);
return
false
;
}
// If it fails, clear it in the destructor.
(
void
)
isContainStub_
.
erase
(
object
);
std
::
u16string
descriptor
=
object
->
GetObjectDescriptor
();
if
(
descriptor
.
empty
())
{
return
false
;
...
...
@@ -277,13 +285,8 @@ IRemoteObject *IPCProcessSkeleton::QueryObjectInner(const std::u16string &descri
{
auto
it
=
objects_
.
find
(
descriptor
);
if
(
it
!=
objects_
.
end
())
{
if
(
it
->
second
==
nullptr
)
{
return
nullptr
;
}
it
->
second
->
AttemptAcquire
(
this
);
return
it
->
second
.
GetRefPtr
();
}
return
nullptr
;
}
...
...
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
浏览文件 @
230bd202
...
...
@@ -568,12 +568,12 @@ bool DBinderDatabusInvoker::OnDatabusSessionClosed(std::shared_ptr<Session> sess
std
::
u16string
descriptor
=
current
->
MakeHandleDescriptor
(
*
it
);
IRemoteObject
*
remoteObject
=
current
->
QueryObject
(
descriptor
);
if
(
remoteObject
!=
nullptr
)
{
(
void
)
current
->
ProxyDetachDBinderSession
(
*
it
);
(
void
)
current
->
DetachHandleToIndex
(
*
it
);
IPCObjectProxy
*
remoteProxy
=
reinterpret_cast
<
IPCObjectProxy
*>
(
remoteObject
);
if
(
remoteProxy
->
IsSubscribeDeathNotice
())
{
remoteProxy
->
SendObituary
();
}
(
void
)
current
->
ProxyDetachDBinderSession
(
*
it
);
(
void
)
current
->
DetachHandleToIndex
(
*
it
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录