Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
e1a660f6
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,发现更多精彩内容 >>
提交
e1a660f6
编写于
9月 07, 2021
作者:
L
liangshenglin1
提交者:
Gitee
9月 07, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug of connectAbility timeout
Signed-off-by:
N
liangshenglin
<
liangshenglin1@huawei.com
>
上级
fc8fa9f1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
31 deletion
+32
-31
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
+1
-1
ipc/native/src/core/include/ipc_process_skeleton.h
ipc/native/src/core/include/ipc_process_skeleton.h
+2
-0
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+22
-26
ipc/native/src/core/source/ipc_process_skeleton.cpp
ipc/native/src/core/source/ipc_process_skeleton.cpp
+7
-4
未找到文件。
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
浏览文件 @
e1a660f6
...
...
@@ -70,7 +70,7 @@ public:
std
::
string
GetDataBusName
();
int
GetProto
()
const
;
void
WaitForInit
(
bool
newProxy
);
void
WaitForInit
();
std
::
u16string
GetInterfaceDescriptor
();
private:
...
...
ipc/native/src/core/include/ipc_process_skeleton.h
浏览文件 @
e1a660f6
...
...
@@ -98,6 +98,7 @@ public:
bool
AttachObject
(
IRemoteObject
*
object
);
bool
AttachObjectInner
(
IRemoteObject
*
object
);
bool
DetachObject
(
IRemoteObject
*
object
);
bool
DetachObjectInner
(
IRemoteObject
*
object
);
bool
OnThreadTerminated
(
const
std
::
string
&
threadName
);
...
...
@@ -207,6 +208,7 @@ private:
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
InvokerRawData
>>
rawData_
;
IPCWorkThreadPool
*
threadPool_
=
nullptr
;
sptr
<
IRemoteObject
>
registryObject_
=
nullptr
;
friend
void
IPCObjectProxy
::
OnLastStrongRef
(
const
void
*
objectId
);
#ifndef CONFIG_IPC_SINGLE
std
::
mutex
databusProcMutex_
;
...
...
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
e1a660f6
...
...
@@ -164,7 +164,7 @@ void IPCObjectProxy::OnFirstStrongRef(const void *objectId)
}
}
void
IPCObjectProxy
::
WaitForInit
(
bool
newProxy
)
void
IPCObjectProxy
::
WaitForInit
()
{
#ifndef CONFIG_IPC_SINGLE
int
type
=
0
;
...
...
@@ -172,7 +172,7 @@ void IPCObjectProxy::WaitForInit(bool newProxy)
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
initMutex_
);
if
(
IsObjectDead
())
{
ZLOG
I
(
LABEL
,
"check a dead proxy, init again"
);
ZLOG
W
(
LABEL
,
"check a dead proxy, init again"
);
isRemoteDead_
=
false
;
isFinishInit_
=
false
;
}
...
...
@@ -182,9 +182,6 @@ void IPCObjectProxy::WaitForInit(bool newProxy)
return
;
}
#ifndef CONFIG_IPC_SINGLE
if
(
newProxy
==
true
)
{
ReleaseProto
();
}
type
=
UpdateProto
();
#endif
isFinishInit_
=
true
;
...
...
@@ -203,15 +200,24 @@ void IPCObjectProxy::OnLastStrongRef(const void *objectId)
ZLOGE
(
LABEL
,
"OnLastStrongRef current is null"
);
return
;
}
if
(
current
->
DetachObject
(
this
))
{
// if detach successfully, this proxy will be destroyed
#ifndef CONFIG_IPC_SINGLE
ReleaseProto
()
;
std
::
shared_ptr
<
DBinderSessionObject
>
session
=
nullptr
;
#endif
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetDefaultInvoker
();
if
(
invoker
!=
nullptr
)
{
invoker
->
ReleaseHandle
(
handle_
);
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
current
->
mutex_
);
if
(
current
->
DetachObjectInner
(
this
)
==
false
)
{
// if detach successfully, this proxy will be destroyed
return
;
}
#ifndef CONFIG_IPC_SINGLE
ReleaseProto
();
session
=
current
->
ProxyQueryDBinderSession
(
handle_
);
(
void
)
current
->
ProxyDetachDBinderSession
(
handle_
);
(
void
)
current
->
DetachHandleToIndex
(
handle_
);
#endif
}
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetDefaultInvoker
();
if
(
invoker
!=
nullptr
)
{
invoker
->
ReleaseHandle
(
handle_
);
}
}
...
...
@@ -231,7 +237,7 @@ bool IPCObjectProxy::AddDeathRecipient(const sptr<DeathRecipient> &recipient)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex_
);
if
(
IsObjectDead
())
{
ZLOG
I
(
LABEL
,
"%s: proxy is already dead"
,
__func__
);
ZLOG
W
(
LABEL
,
"%s: proxy is already dead"
,
__func__
);
return
false
;
}
...
...
@@ -269,9 +275,9 @@ bool IPCObjectProxy::AddDeathRecipient(const sptr<DeathRecipient> &recipient)
#ifndef CONFIG_IPC_SINGLE
if
(
proto_
==
IRemoteObject
::
IF_PROT_DATABUS
)
{
status
=
AddDbinderDeathRecipient
();
ZLOGE
(
LABEL
,
"%s: fail to add dbinder death recipient, status = %d"
,
__func__
,
status
);
#ifndef BUILD_PUBLIC_VERSION
if
(
!
status
)
{
ZLOGE
(
LABEL
,
"failed to add dbinder death recipient"
);
ReportDriverEvent
(
DbinderErrorCode
::
COMMON_DRIVER_ERROR
,
DbinderErrorCode
::
ERROR_TYPE
,
DbinderErrorCode
::
RPC_DRIVER
,
DbinderErrorCode
::
ERROR_CODE
,
DbinderErrorCode
::
SET_DEATH_RECIPIENT_FAILURE
);
...
...
@@ -593,8 +599,8 @@ void IPCObjectProxy::ReleaseDatabusProto()
return
;
}
if
(
GetProto
()
!=
IRemoteObject
::
IF_PROT_DATABUS
)
{
ZLOG
I
(
LABEL
,
"not databus dbinder, need do nothing"
);
if
(
proto_
!=
IRemoteObject
::
IF_PROT_DATABUS
)
{
ZLOG
W
(
LABEL
,
"not databus dbinder, need do nothing"
);
return
;
}
...
...
@@ -602,19 +608,9 @@ void IPCObjectProxy::ReleaseDatabusProto()
MessageOption
option
=
{
MessageOption
::
TF_ASYNC
};
uint32_t
err
=
SendRequestInner
(
false
,
DBINDER_DECREFS_TRANSACTION
,
data
,
reply
,
option
);
if
(
err
!=
ERR_NONE
)
{
ZLOG
E
(
LABEL
,
"DBINDER_DECREFS_TRANSACTION transact return error = %{public}u"
,
err
);
ZLOG
W
(
LABEL
,
"DBINDER_DECREFS_TRANSACTION transact return error = %{public}u"
,
err
);
// do nothing
}
IPCProcessSkeleton
*
current
=
IPCProcessSkeleton
::
GetCurrent
();
if
(
current
==
nullptr
)
{
ZLOGE
(
LABEL
,
"release proto current is null"
);
return
;
}
(
void
)
current
->
ProxyDetachDBinderSession
(
handle_
);
(
void
)
current
->
DetachHandleToIndex
(
handle_
);
return
;
}
void
IPCObjectProxy
::
ReleaseBinderProto
()
...
...
ipc/native/src/core/source/ipc_process_skeleton.cpp
浏览文件 @
e1a660f6
...
...
@@ -124,7 +124,6 @@ std::u16string IPCProcessSkeleton::MakeHandleDescriptor(int handle)
IRemoteObject
*
IPCProcessSkeleton
::
FindOrNewObject
(
int
handle
)
{
bool
newProxy
=
false
;
IRemoteObject
*
remoteObject
=
nullptr
;
std
::
u16string
descriptor
=
MakeHandleDescriptor
(
handle
);
{
...
...
@@ -135,7 +134,7 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
if
(
handle
==
REGISTRY_HANDLE
)
{
IRemoteInvoker
*
invoker
=
IPCThreadSkeleton
::
GetRemoteInvoker
(
IRemoteObject
::
IF_PROT_DEFAULT
);
if
(
invoker
==
nullptr
)
{
DBINDER_LOGE
(
"fail to get invoker"
);
DBINDER_LOGE
(
"fail
ed
to get invoker"
);
return
nullptr
;
}
if
(
!
invoker
->
PingService
(
REGISTRY_HANDLE
))
{
...
...
@@ -144,7 +143,6 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
}
}
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
);
...
...
@@ -159,7 +157,7 @@ IRemoteObject *IPCProcessSkeleton::FindOrNewObject(int handle)
}
IPCObjectProxy
*
remoteProxy
=
reinterpret_cast
<
IPCObjectProxy
*>
(
remoteObject
);
remoteProxy
->
WaitForInit
(
newProxy
);
remoteProxy
->
WaitForInit
();
return
remoteObject
;
}
...
...
@@ -237,6 +235,11 @@ bool IPCProcessSkeleton::IsContainsObject(IRemoteObject *object)
bool
IPCProcessSkeleton
::
DetachObject
(
IRemoteObject
*
object
)
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
mutex_
);
return
DetachObjectInner
(
object
);
}
bool
IPCProcessSkeleton
::
DetachObjectInner
(
IRemoteObject
*
object
)
{
int
strongRef
=
object
->
GetSptrRefCount
();
if
(
strongRef
>
0
)
{
DBINDER_LOGI
(
"proxy is still strong referenced:%{public}d"
,
strongRef
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录