Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
c3cd425f
C
communication_ipc
项目概览
OpenHarmony
/
communication_ipc
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
c3cd425f
编写于
8月 06, 2022
作者:
F
fanxiaoyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix rpc session bug when there are more than one SA in open process.
Signed-off-by:
N
fanxiaoyu
<
fanxiaoyu3@huawei.com
>
上级
2bf73ced
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
37 addition
and
41 deletion
+37
-41
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
+2
-3
interfaces/innerkits/ipc_core/include/ipc_object_stub.h
interfaces/innerkits/ipc_core/include/ipc_object_stub.h
+2
-2
interfaces/innerkits/libdbinder/include/dbinder_service.h
interfaces/innerkits/libdbinder/include/dbinder_service.h
+1
-1
ipc/native/src/core/source/ipc_object_proxy.cpp
ipc/native/src/core/source/ipc_object_proxy.cpp
+11
-14
ipc/native/src/core/source/ipc_object_stub.cpp
ipc/native/src/core/source/ipc_object_stub.cpp
+11
-9
ipc/native/src/core/source/ipc_process_skeleton.cpp
ipc/native/src/core/source/ipc_process_skeleton.cpp
+0
-4
ipc/native/src/mock/source/binder_invoker.cpp
ipc/native/src/mock/source/binder_invoker.cpp
+5
-3
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
+2
-2
services/dbinder/dbinder_service/src/dbinder_service.cpp
services/dbinder/dbinder_service/src/dbinder_service.cpp
+3
-3
未找到文件。
interfaces/innerkits/ipc_core/include/ipc_object_proxy.h
浏览文件 @
c3cd425f
...
...
@@ -66,9 +66,8 @@ public:
int
InvokeListenThread
(
MessageParcel
&
data
,
MessageParcel
&
reply
);
int32_t
NoticeServiceDie
();
std
::
string
GetPidAndUidInfo
();
std
::
string
GetDataBusName
();
std
::
string
GetPidAndUidInfo
(
int32_t
systemAbilityId
);
std
::
string
GetDataBusName
(
int32_t
systemAbilityId
);
std
::
string
TransDataBusName
(
uint32_t
uid
,
uint32_t
pid
);
int
GetProto
()
const
;
void
WaitForInit
();
...
...
interfaces/innerkits/ipc_core/include/ipc_object_stub.h
浏览文件 @
c3cd425f
...
...
@@ -83,8 +83,8 @@ public:
private:
int32_t
GrantDataBusName
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
);
int32_t
TransDataBusName
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
);
std
::
string
CreateDatabusName
(
int
uid
,
int
pid
);
std
::
string
GetDataBusName
();
std
::
string
CreateDatabusName
(
int
uid
,
int
pid
,
int
systemAbilityId
);
std
::
string
GetDataBusName
(
int32_t
systemAbilityId
);
bool
IsSamgrCall
(
uint32_t
accessToken
);
bool
HasDumpPermission
(
uint32_t
accessToken
)
const
;
#endif
...
...
interfaces/innerkits/libdbinder/include/dbinder_service.h
浏览文件 @
c3cd425f
...
...
@@ -160,7 +160,7 @@ private:
bool
OnRemoteInvokerDataBusMessage
(
IPCObjectProxy
*
proxy
,
struct
DHandleEntryTxRx
*
replyMessage
,
std
::
string
&
remoteDeviceId
,
int
pid
,
int
uid
);
bool
IsDeviceIdIllegal
(
const
std
::
string
&
deviceID
);
std
::
string
GetDatabusNameByProxy
(
IPCObjectProxy
*
proxy
);
std
::
string
GetDatabusNameByProxy
(
IPCObjectProxy
*
proxy
,
int32_t
systemAbilityId
);
uint32_t
GetSeqNumber
();
bool
RegisterRemoteProxyInner
(
std
::
u16string
serviceName
,
binder_uintptr_t
binder
);
bool
CheckSystemAbilityId
(
int32_t
systemAbilityId
);
...
...
ipc/native/src/core/source/ipc_object_proxy.cpp
浏览文件 @
c3cd425f
...
...
@@ -145,11 +145,12 @@ std::u16string IPCObjectProxy::GetInterfaceDescriptor()
return
remoteDescriptor_
;
}
std
::
string
IPCObjectProxy
::
GetPidAndUidInfo
()
std
::
string
IPCObjectProxy
::
GetPidAndUidInfo
(
int32_t
systemAbilityId
)
{
MessageParcel
data
,
reply
;
MessageOption
option
;
data
.
WriteInt32
(
systemAbilityId
);
int32_t
err
=
SendRequestInner
(
false
,
GET_UIDPID_INFO
,
data
,
reply
,
option
);
if
(
err
!=
ERR_NONE
)
{
ZLOGE
(
LABEL
,
"GetPidAndUidInfo SendRequestInner return error = %{public}d"
,
err
);
...
...
@@ -158,11 +159,12 @@ std::string IPCObjectProxy::GetPidAndUidInfo()
return
reply
.
ReadString
();
}
std
::
string
IPCObjectProxy
::
GetDataBusName
()
std
::
string
IPCObjectProxy
::
GetDataBusName
(
int32_t
systemAbilityId
)
{
MessageParcel
data
,
reply
;
MessageOption
option
;
data
.
WriteInt32
(
systemAbilityId
);
int32_t
err
=
SendRequestInner
(
false
,
GRANT_DATABUS_NAME
,
data
,
reply
,
option
);
if
(
err
!=
ERR_NONE
)
{
ZLOGE
(
LABEL
,
"GetDataBusName transact return error = %{public}d"
,
err
);
...
...
@@ -260,21 +262,16 @@ void IPCObjectProxy::OnLastStrongRef(const void *objectId)
ZLOGE
(
LABEL
,
"OnLastStrongRef current is null"
);
return
;
}
if
(
current
->
DetachObject
(
this
)
==
false
)
{
// if detach successfully, this proxy will be destroyed
return
;
}
#ifndef CONFIG_IPC_SINGLE
ReleaseProto
();
std
::
shared_ptr
<
DBinderSessionObject
>
session
=
nullptr
;
session
=
current
->
ProxyQueryDBinderSession
(
handle_
);
(
void
)
current
->
ProxyDetachDBinderSession
(
handle_
);
(
void
)
current
->
DetachHandleToIndex
(
handle_
);
#endif
{
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_
);
...
...
ipc/native/src/core/source/ipc_object_stub.cpp
浏览文件 @
c3cd425f
...
...
@@ -241,7 +241,8 @@ int IPCObjectStub::SendRequest(uint32_t code, MessageParcel &data, MessageParcel
result
=
IPC_STUB_INVALID_DATA_ERR
;
break
;
}
std
::
string
sessionName
=
GetDataBusName
();
int32_t
systemAbilityId
=
data
.
ReadInt32
();
std
::
string
sessionName
=
GetDataBusName
(
systemAbilityId
);
if
(
sessionName
.
empty
())
{
ZLOGE
(
LABEL
,
"sessionName is empty"
);
result
=
IPC_STUB_CREATE_BUS_SERVER_ERR
;
...
...
@@ -456,7 +457,6 @@ int32_t IPCObjectStub::IncStubRefs(MessageParcel &data, MessageParcel &reply)
ZLOGE
(
LABEL
,
"%s: current is null"
,
__func__
);
return
IPC_STUB_CURRENT_NULL_ERR
;
}
std
::
string
deviceId
=
IPCSkeleton
::
GetCallingDeviceID
();
if
(
deviceId
.
empty
())
{
ZLOGE
(
LABEL
,
"%s: calling error"
,
__func__
);
...
...
@@ -466,11 +466,9 @@ int32_t IPCObjectStub::IncStubRefs(MessageParcel &data, MessageParcel &reply)
ZLOGE
(
LABEL
,
"%s: attach stub ref info err, already in"
,
__func__
);
return
ERR_NONE
;
}
if
(
!
current
->
DecStubRefTimes
(
this
))
{
this
->
IncStrongRef
(
this
);
}
return
ERR_NONE
;
}
...
...
@@ -531,7 +529,7 @@ int32_t IPCObjectStub::AddAuthInfo(MessageParcel &data, MessageParcel &reply, ui
return
ERR_NONE
;
}
std
::
string
IPCObjectStub
::
GetDataBusName
()
std
::
string
IPCObjectStub
::
GetDataBusName
(
int32_t
systemAbilityId
)
{
IPCProcessSkeleton
*
current
=
IPCProcessSkeleton
::
GetCurrent
();
if
(
current
==
nullptr
)
{
...
...
@@ -545,14 +543,15 @@ std::string IPCObjectStub::GetDataBusName()
}
IPCObjectProxy
*
samgr
=
reinterpret_cast
<
IPCObjectProxy
*>
(
object
.
GetRefPtr
());
return
samgr
->
GetDataBusName
();
return
samgr
->
GetDataBusName
(
systemAbilityId
);
}
int32_t
IPCObjectStub
::
GrantDataBusName
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
)
{
int
pid
=
IPCSkeleton
::
GetCallingPid
();
int
uid
=
IPCSkeleton
::
GetCallingUid
();
std
::
string
sessionName
=
CreateDatabusName
(
uid
,
pid
);
int
systemAbilityId
=
data
.
ReadInt32
();
std
::
string
sessionName
=
CreateDatabusName
(
uid
,
pid
,
systemAbilityId
);
if
(
sessionName
.
empty
())
{
ZLOGE
(
LABEL
,
"pid/uid is invalid, pid = {public}%d, uid = {public}%d"
,
pid
,
uid
);
return
IPC_STUB_INVALID_DATA_ERR
;
...
...
@@ -573,7 +572,7 @@ int32_t IPCObjectStub::TransDataBusName(uint32_t code, MessageParcel &data, Mess
ZLOGE
(
LABEL
,
"pid/uid is invalid, pid = {public}%d, uid = {public}%d"
,
remotePid
,
remoteUid
);
return
IPC_STUB_INVALID_DATA_ERR
;
}
std
::
string
sessionName
=
CreateDatabusName
(
remoteUid
,
remotePid
);
std
::
string
sessionName
=
CreateDatabusName
(
remoteUid
,
remotePid
,
0
);
if
(
sessionName
.
empty
())
{
ZLOGE
(
LABEL
,
"pid/uid is invalid, pid = {public}%d, uid = {public}%d"
,
remotePid
,
remoteUid
);
return
IPC_STUB_INVALID_DATA_ERR
;
...
...
@@ -586,7 +585,7 @@ int32_t IPCObjectStub::TransDataBusName(uint32_t code, MessageParcel &data, Mess
return
ERR_NONE
;
}
std
::
string
IPCObjectStub
::
CreateDatabusName
(
int
uid
,
int
pid
)
std
::
string
IPCObjectStub
::
CreateDatabusName
(
int
uid
,
int
pid
,
int
systemAbilityId
)
{
std
::
shared_ptr
<
ISessionService
>
softbusManager
=
ISessionService
::
GetInstance
();
if
(
softbusManager
==
nullptr
)
{
...
...
@@ -595,6 +594,9 @@ std::string IPCObjectStub::CreateDatabusName(int uid, int pid)
}
std
::
string
sessionName
=
"DBinder"
+
std
::
to_string
(
uid
)
+
std
::
string
(
"_"
)
+
std
::
to_string
(
pid
);
if
(
systemAbilityId
>
0
)
{
sessionName
+=
std
::
string
(
"_"
)
+
std
::
to_string
(
systemAbilityId
);
}
if
(
softbusManager
->
GrantPermission
(
uid
,
pid
,
sessionName
)
!=
ERR_NONE
)
{
ZLOGE
(
LABEL
,
"fail to Grant Permission softbus name"
);
return
""
;
...
...
ipc/native/src/core/source/ipc_process_skeleton.cpp
浏览文件 @
c3cd425f
...
...
@@ -467,7 +467,6 @@ bool IPCProcessSkeleton::QueryProxyBySessionHandle(uint32_t handle, std::vector<
proxyHandle
.
push_back
(
it
->
first
);
}
}
return
true
;
}
...
...
@@ -1207,7 +1206,6 @@ bool IPCProcessSkeleton::AttachCommAuthInfo(IRemoteObject *stub, int pid, int ui
auto
check
=
[
&
stub
,
&
pid
,
&
uid
,
&
deviceId
,
this
](
const
std
::
shared_ptr
<
CommAuthInfo
>
&
auth
)
{
return
IsSameRemoteObject
(
stub
,
pid
,
uid
,
deviceId
,
auth
);
};
std
::
unique_lock
<
std
::
shared_mutex
>
lockGuard
(
commAuthMutex_
);
auto
it
=
std
::
find_if
(
commAuth_
.
begin
(),
commAuth_
.
end
(),
check
);
if
(
it
!=
commAuth_
.
end
())
{
...
...
@@ -1225,7 +1223,6 @@ void IPCProcessSkeleton::DetachCommAuthInfo(IRemoteObject *stub, int pid, int ui
auto
check
=
[
&
stub
,
&
pid
,
&
uid
,
&
deviceId
,
this
](
const
std
::
shared_ptr
<
CommAuthInfo
>
&
auth
)
{
return
IsSameRemoteObject
(
stub
,
pid
,
uid
,
deviceId
,
auth
);
};
std
::
unique_lock
<
std
::
shared_mutex
>
lockGuard
(
commAuthMutex_
);
commAuth_
.
remove_if
(
check
);
}
...
...
@@ -1235,7 +1232,6 @@ std::shared_ptr<FeatureSetData> IPCProcessSkeleton::QueryIsAuth(int pid, int uid
auto
check
=
[
&
pid
,
&
uid
,
&
deviceId
,
this
](
const
std
::
shared_ptr
<
CommAuthInfo
>
&
auth
)
{
return
IsSameRemoteObject
(
pid
,
uid
,
deviceId
,
auth
);
};
std
::
shared_lock
<
std
::
shared_mutex
>
lockGuard
(
commAuthMutex_
);
auto
it
=
std
::
find_if
(
commAuth_
.
begin
(),
commAuth_
.
end
(),
check
);
if
(
it
!=
commAuth_
.
end
())
{
...
...
ipc/native/src/mock/source/binder_invoker.cpp
浏览文件 @
c3cd425f
...
...
@@ -570,7 +570,7 @@ int BinderInvoker::HandleReply(MessageParcel *reply)
int
BinderInvoker
::
HandleCommandsInner
(
uint32_t
cmd
)
{
int
error
=
ERR_NONE
;
ZLOGD
(
LABEL
,
"HandleCommands:cmd:%{public}u
\n
"
,
cmd
);
ZLOGD
(
LABEL
,
"HandleCommands:cmd:%{public}u"
,
cmd
);
switch
(
cmd
)
{
case
BR_ERROR
:
error
=
input_
.
ReadInt32
();
...
...
@@ -679,7 +679,7 @@ int BinderInvoker::TransactWithDriver(bool doRead)
bwr
.
write_consumed
=
0
;
bwr
.
read_consumed
=
0
;
ZLOGD
(
LABEL
,
"TransactWithDriver write_size:%lld, read_size:%lld
\n
"
,
bwr
.
write_size
,
bwr
.
read_size
);
ZLOGD
(
LABEL
,
"TransactWithDriver write_size:%lld, read_size:%lld"
,
bwr
.
write_size
,
bwr
.
read_size
);
int
error
=
binderConnector_
->
WriteBinder
(
BINDER_WRITE_READ
,
&
bwr
);
if
(
bwr
.
write_consumed
>
0
)
{
if
(
bwr
.
write_consumed
<
output_
.
GetDataSize
())
{
...
...
@@ -693,7 +693,7 @@ int BinderInvoker::TransactWithDriver(bool doRead)
input_
.
RewindRead
(
0
);
}
if
(
error
!=
ERR_NONE
)
{
ZLOGE
(
LABEL
,
"TransactWithDriver result = %{public}d
\n
"
,
error
);
ZLOGE
(
LABEL
,
"TransactWithDriver result = %{public}d"
,
error
);
}
return
error
;
...
...
@@ -908,6 +908,8 @@ bool BinderInvoker::FlattenObject(Parcel &parcel, const IRemoteObject *object) c
flat
.
hdr
.
type
=
BINDER_TYPE_BINDER
;
flat
.
binder
=
reinterpret_cast
<
uintptr_t
>
(
object
);
flat
.
cookie
=
flat
.
binder
;
ZLOGD
(
LABEL
,
"write stub object: %{public}s, ptr=%{public}p"
,
Str16ToStr8
(
object
->
GetObjectDescriptor
()).
c_str
(),
object
);
}
flat
.
flags
=
0x7f
|
FLAT_BINDER_FLAG_ACCEPTS_FDS
;
...
...
ipc/native/src/mock/source/dbinder_databus_invoker.cpp
浏览文件 @
c3cd425f
...
...
@@ -79,7 +79,6 @@ std::shared_ptr<DBinderSessionObject> DBinderDatabusInvoker::NewSessionOfBinderP
DBINDER_LOGE
(
"current ipc process skeleton is nullptr"
);
return
nullptr
;
}
sptr
<
IPCObjectProxy
>
ipcProxy
=
reinterpret_cast
<
IPCObjectProxy
*>
(
current
->
FindOrNewObject
(
handle
).
GetRefPtr
());
if
(
ipcProxy
==
nullptr
)
{
DBINDER_LOGE
(
"attempt to send a invalid handle = %u"
,
handle
);
...
...
@@ -91,7 +90,7 @@ std::shared_ptr<DBinderSessionObject> DBinderDatabusInvoker::NewSessionOfBinderP
return
nullptr
;
}
std
::
string
sessionName
=
ipcProxy
->
GetPidAndUidInfo
();
std
::
string
sessionName
=
ipcProxy
->
GetPidAndUidInfo
(
0
);
if
(
sessionName
.
empty
())
{
DBINDER_LOGE
(
"get bus name error"
);
return
nullptr
;
...
...
@@ -324,6 +323,7 @@ void DBinderDatabusInvoker::OnMessageAvailable(std::shared_ptr<Session> session,
readSize
+=
packageSize
;
}
else
{
// If the current is abnormal, the subsequent is no longer processed.
DBINDER_LOGE
(
"not complete message"
);
break
;
}
}
while
(
readSize
+
sizeof
(
dbinder_transaction_data
)
<
static_cast
<
uint32_t
>
(
len
));
...
...
services/dbinder/dbinder_service/src/dbinder_service.cpp
浏览文件 @
c3cd425f
...
...
@@ -490,7 +490,7 @@ bool DBinderService::OnRemoteInvokerMessage(const struct DHandleEntryTxRx *messa
return
true
;
}
std
::
string
DBinderService
::
GetDatabusNameByProxy
(
IPCObjectProxy
*
proxy
)
std
::
string
DBinderService
::
GetDatabusNameByProxy
(
IPCObjectProxy
*
proxy
,
int32_t
systemAbilityId
)
{
if
(
proxy
==
nullptr
)
{
DBINDER_LOGE
(
"proxy can not be null"
);
...
...
@@ -501,7 +501,7 @@ std::string DBinderService::GetDatabusNameByProxy(IPCObjectProxy *proxy)
DBINDER_LOGI
(
"sessionName has been granded"
);
return
sessionName
;
}
sessionName
=
proxy
->
GetPidAndUidInfo
();
sessionName
=
proxy
->
GetPidAndUidInfo
(
systemAbilityId
);
if
(
sessionName
.
empty
())
{
DBINDER_LOGE
(
"grand session name failed"
);
return
""
;
...
...
@@ -556,7 +556,7 @@ bool DBinderService::OnRemoteInvokerDataBusMessage(IPCObjectProxy *proxy, struct
DBINDER_LOGE
(
"remote device id is error"
);
return
false
;
}
std
::
string
sessionName
=
GetDatabusNameByProxy
(
proxy
);
std
::
string
sessionName
=
GetDatabusNameByProxy
(
proxy
,
replyMessage
->
stubIndex
);
if
(
sessionName
.
empty
())
{
DBINDER_LOGE
(
"get bus name fail"
);
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录