Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
fe48697b
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,发现更多精彩内容 >>
未验证
提交
fe48697b
编写于
6月 08, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
!704 修改dbinderService传递stub指针
Merge pull request !704 from Yippo/master
上级
bf293bbe
bebcfa2d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
5 deletion
+50
-5
interfaces/innerkits/libdbinder/include/dbinder_service.h
interfaces/innerkits/libdbinder/include/dbinder_service.h
+6
-0
services/dbinder/dbinder_service/src/dbinder_service.cpp
services/dbinder/dbinder_service/src/dbinder_service.cpp
+44
-5
未找到文件。
interfaces/innerkits/libdbinder/include/dbinder_service.h
浏览文件 @
fe48697b
...
@@ -325,6 +325,8 @@ private:
...
@@ -325,6 +325,8 @@ private:
bool
SendEntryToRemote
(
const
sptr
<
DBinderServiceStub
>
stub
,
uint32_t
seqNumber
,
uint32_t
pid
,
uint32_t
uid
);
bool
SendEntryToRemote
(
const
sptr
<
DBinderServiceStub
>
stub
,
uint32_t
seqNumber
,
uint32_t
pid
,
uint32_t
uid
);
uint16_t
AllocFreeSocketPort
();
uint16_t
AllocFreeSocketPort
();
std
::
string
GetLocalDeviceID
();
std
::
string
GetLocalDeviceID
();
binder_uintptr_t
AddStubByTag
(
binder_uintptr_t
stub
);
binder_uintptr_t
QueryStubPtr
(
binder_uintptr_t
stub
);
bool
CheckBinderObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
binder_uintptr_t
binderObject
);
bool
CheckBinderObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
binder_uintptr_t
binderObject
);
bool
HasDBinderStub
(
binder_uintptr_t
binderObject
);
bool
HasDBinderStub
(
binder_uintptr_t
binderObject
);
bool
IsSameStubObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
const
std
::
u16string
&
service
,
bool
IsSameStubObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
const
std
::
u16string
&
service
,
...
@@ -380,6 +382,10 @@ private:
...
@@ -380,6 +382,10 @@ private:
std
::
mutex
threadPoolMutex_
;
std
::
mutex
threadPoolMutex_
;
uint32_t
seqNumber_
=
0
;
/* indicate make remote binder message sequence number, and can be overflow */
uint32_t
seqNumber_
=
0
;
/* indicate make remote binder message sequence number, and can be overflow */
/* indicate the stub flag used for negotiation with the peer end, and can be overflow */
binder_uintptr_t
stubTagNum_
=
1
;
std
::
map
<
binder_uintptr_t
,
binder_uintptr_t
>
mapDBinderStubRegisters_
;
std
::
list
<
sptr
<
DBinderServiceStub
>>
DBinderStubRegisted_
;
std
::
list
<
sptr
<
DBinderServiceStub
>>
DBinderStubRegisted_
;
std
::
map
<
std
::
u16string
,
binder_uintptr_t
>
mapRemoteBinderObjects_
;
std
::
map
<
std
::
u16string
,
binder_uintptr_t
>
mapRemoteBinderObjects_
;
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
struct
ThreadLockInfo
>>
threadLockInfo_
;
std
::
map
<
uint32_t
,
std
::
shared_ptr
<
struct
ThreadLockInfo
>>
threadLockInfo_
;
...
...
services/dbinder/dbinder_service/src/dbinder_service.cpp
浏览文件 @
fe48697b
...
@@ -49,6 +49,7 @@ DBinderService::~DBinderService()
...
@@ -49,6 +49,7 @@ DBinderService::~DBinderService()
StopRemoteListener
();
StopRemoteListener
();
DBinderStubRegisted_
.
clear
();
DBinderStubRegisted_
.
clear
();
mapDBinderStubRegisters_
.
clear
();
mapRemoteBinderObjects_
.
clear
();
mapRemoteBinderObjects_
.
clear
();
threadLockInfo_
.
clear
();
threadLockInfo_
.
clear
();
proxyObject_
.
clear
();
proxyObject_
.
clear
();
...
@@ -177,6 +178,38 @@ bool DBinderService::IsDeviceIdIllegal(const std::string &deviceID)
...
@@ -177,6 +178,38 @@ bool DBinderService::IsDeviceIdIllegal(const std::string &deviceID)
return
false
;
return
false
;
}
}
binder_uintptr_t
DBinderService
::
AddStubByTag
(
binder_uintptr_t
stub
)
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
handleEntryMutex_
);
// the same stub needs add stubNum to mapDBinderStubRegisters_, the previous corresponding stubNum will be returned.
for
(
auto
iter
=
mapDBinderStubRegisters_
.
begin
();
iter
!=
mapDBinderStubRegisters_
.
end
();
iter
++
)
{
if
(
iter
->
second
==
stub
)
{
return
iter
->
first
;
}
}
binder_uintptr_t
stubTag
=
stubTagNum_
++
;
auto
result
=
mapDBinderStubRegisters_
.
insert
(
std
::
pair
<
binder_uintptr_t
,
binder_uintptr_t
>
(
stubTag
,
stub
));
if
(
result
.
second
)
{
return
stubTag
;
}
else
{
return
0
;
}
}
binder_uintptr_t
DBinderService
::
QueryStubPtr
(
binder_uintptr_t
stubTag
)
{
std
::
lock_guard
<
std
::
mutex
>
lockGuard
(
handleEntryMutex_
);
auto
iter
=
mapDBinderStubRegisters_
.
find
(
stubTag
);
if
(
iter
!=
mapDBinderStubRegisters_
.
end
())
{
return
iter
->
second
;
}
return
0
;
}
bool
DBinderService
::
CheckBinderObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
binder_uintptr_t
stubPtr
)
bool
DBinderService
::
CheckBinderObject
(
const
sptr
<
DBinderServiceStub
>
&
stub
,
binder_uintptr_t
stubPtr
)
{
{
if
(
stub
==
nullptr
)
{
if
(
stub
==
nullptr
)
{
...
@@ -241,6 +274,12 @@ bool DBinderService::DeleteDBinderStub(const std::u16string &service, const std:
...
@@ -241,6 +274,12 @@ bool DBinderService::DeleteDBinderStub(const std::u16string &service, const std:
if
(
it
==
DBinderStubRegisted_
.
end
())
{
if
(
it
==
DBinderStubRegisted_
.
end
())
{
return
false
;
return
false
;
}
}
for
(
auto
mapIt
=
mapDBinderStubRegisters_
.
begin
();
mapIt
!=
mapDBinderStubRegisters_
.
end
();
mapIt
++
)
{
if
(
mapIt
->
second
==
reinterpret_cast
<
binder_uintptr_t
>
((
*
it
).
GetRefPtr
()))
{
mapDBinderStubRegisters_
.
erase
(
mapIt
);
}
}
DBinderStubRegisted_
.
erase
(
it
);
DBinderStubRegisted_
.
erase
(
it
);
return
true
;
return
true
;
}
}
...
@@ -328,7 +367,7 @@ bool DBinderService::SendEntryToRemote(const sptr<DBinderServiceStub> stub, uint
...
@@ -328,7 +367,7 @@ bool DBinderService::SendEntryToRemote(const sptr<DBinderServiceStub> stub, uint
message
->
stubIndex
=
static_cast
<
uint64_t
>
(
std
::
atoi
(
stub
->
GetServiceName
().
c_str
()));
message
->
stubIndex
=
static_cast
<
uint64_t
>
(
std
::
atoi
(
stub
->
GetServiceName
().
c_str
()));
message
->
seqNumber
=
seqNumber
;
message
->
seqNumber
=
seqNumber
;
message
->
binderObject
=
stub
->
GetBinderObject
();
message
->
binderObject
=
stub
->
GetBinderObject
();
message
->
stub
=
reinterpret_cast
<
binder_uintptr_t
>
(
stub
.
GetRefPtr
(
));
message
->
stub
=
AddStubByTag
(
reinterpret_cast
<
binder_uintptr_t
>
(
stub
.
GetRefPtr
()
));
message
->
deviceIdInfo
.
tokenId
=
IPCSkeleton
::
GetCallingTokenID
();
message
->
deviceIdInfo
.
tokenId
=
IPCSkeleton
::
GetCallingTokenID
();
message
->
pid
=
pid
;
message
->
pid
=
pid
;
message
->
uid
=
uid
;
message
->
uid
=
uid
;
...
@@ -785,7 +824,7 @@ bool DBinderService::IsSameSession(std::shared_ptr<struct SessionInfo> oldSessio
...
@@ -785,7 +824,7 @@ bool DBinderService::IsSameSession(std::shared_ptr<struct SessionInfo> oldSessio
void
DBinderService
::
MakeSessionByReplyMessage
(
const
struct
DHandleEntryTxRx
*
replyMessage
)
void
DBinderService
::
MakeSessionByReplyMessage
(
const
struct
DHandleEntryTxRx
*
replyMessage
)
{
{
if
(
HasDBinderStub
(
replyMessage
->
stub
)
==
false
)
{
if
(
HasDBinderStub
(
QueryStubPtr
(
replyMessage
->
stub
)
)
==
false
)
{
DBINDER_LOGE
(
LOG_LABEL
,
"invalid stub object"
);
DBINDER_LOGE
(
LOG_LABEL
,
"invalid stub object"
);
return
;
return
;
}
}
...
@@ -820,7 +859,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
...
@@ -820,7 +859,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
return
;
return
;
}
}
// check whether need to update session
// check whether need to update session
std
::
shared_ptr
<
struct
SessionInfo
>
oldSession
=
QuerySessionObject
(
replyMessage
->
stub
);
std
::
shared_ptr
<
struct
SessionInfo
>
oldSession
=
QuerySessionObject
(
QueryStubPtr
(
replyMessage
->
stub
)
);
if
(
oldSession
!=
nullptr
)
{
if
(
oldSession
!=
nullptr
)
{
if
(
IsSameSession
(
oldSession
,
session
)
==
true
)
{
if
(
IsSameSession
(
oldSession
,
session
)
==
true
)
{
DBINDER_LOGI
(
LOG_LABEL
,
"invoker remote session already, do nothing"
);
DBINDER_LOGI
(
LOG_LABEL
,
"invoker remote session already, do nothing"
);
...
@@ -829,7 +868,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
...
@@ -829,7 +868,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
// ignore seqNumber overflow here, greater seqNumber means later request
// ignore seqNumber overflow here, greater seqNumber means later request
if
(
oldSession
->
seqNumber
<
session
->
seqNumber
)
{
if
(
oldSession
->
seqNumber
<
session
->
seqNumber
)
{
// remote old session
// remote old session
if
(
!
DetachSessionObject
(
replyMessage
->
stub
))
{
if
(
!
DetachSessionObject
(
QueryStubPtr
(
replyMessage
->
stub
)
))
{
DBINDER_LOGE
(
LOG_LABEL
,
"failed to detach session object"
);
DBINDER_LOGE
(
LOG_LABEL
,
"failed to detach session object"
);
}
}
}
else
{
}
else
{
...
@@ -839,7 +878,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
...
@@ -839,7 +878,7 @@ void DBinderService::MakeSessionByReplyMessage(const struct DHandleEntryTxRx *re
}
}
}
}
if
(
!
AttachSessionObject
(
session
,
replyMessage
->
stub
))
{
if
(
!
AttachSessionObject
(
session
,
QueryStubPtr
(
replyMessage
->
stub
)
))
{
DBINDER_LOGE
(
LOG_LABEL
,
"attach SessionInfo fail"
);
DBINDER_LOGE
(
LOG_LABEL
,
"attach SessionInfo fail"
);
return
;
return
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录