Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
aba5a43c
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,发现更多精彩内容 >>
未验证
提交
aba5a43c
编写于
1月 19, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!103 【RPC】RPC支持跨设备服务管理
Merge pull request !103 from pilipala195/master
上级
348f3059
ef50e2ad
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
251 addition
and
200 deletion
+251
-200
interfaces/innerkits/c/dbinder/include/dbinder_service.h
interfaces/innerkits/c/dbinder/include/dbinder_service.h
+0
-26
ipc/native/c/manager/include/ipc_process_skeleton.h
ipc/native/c/manager/include/ipc_process_skeleton.h
+1
-1
ipc/native/c/manager/include/ipc_thread_pool.h
ipc/native/c/manager/include/ipc_thread_pool.h
+1
-1
ipc/native/c/manager/src/ipc_process_skeleton.c
ipc/native/c/manager/src/ipc_process_skeleton.c
+4
-4
ipc/native/c/manager/src/serializer.c
ipc/native/c/manager/src/serializer.c
+2
-2
ipc/native/c/rpc/include/rpc_process_skeleton.h
ipc/native/c/rpc/include/rpc_process_skeleton.h
+3
-3
ipc/native/c/rpc/ipc_adapter/include/ipc_proxy_inner.h
ipc/native/c/rpc/ipc_adapter/include/ipc_proxy_inner.h
+1
-1
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
+10
-8
ipc/native/c/rpc/ipc_adapter/small/ipc_proxy_inner.c
ipc/native/c/rpc/ipc_adapter/small/ipc_proxy_inner.c
+4
-4
ipc/native/c/rpc/src/dbinder_invoker.c
ipc/native/c/rpc/src/dbinder_invoker.c
+21
-20
ipc/native/c/rpc/src/rpc_process_skeleton.c
ipc/native/c/rpc/src/rpc_process_skeleton.c
+5
-7
ipc/native/c/rpc/src/rpc_process_skeleton_virtual.c
ipc/native/c/rpc/src/rpc_process_skeleton_virtual.c
+1
-1
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
+1
-1
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
+0
-9
ipc/test/rpc/client/rpc_client.c
ipc/test/rpc/client/rpc_client.c
+1
-6
ipc/test/rpc/include/rpc_mini_samgr.h
ipc/test/rpc/include/rpc_mini_samgr.h
+3
-3
ipc/test/rpc/samgr/rpc_mini_samgr.c
ipc/test/rpc/samgr/rpc_mini_samgr.c
+34
-11
ipc/test/rpc/samgr/rpc_samgr.c
ipc/test/rpc/samgr/rpc_samgr.c
+1
-0
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
+0
-1
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
+17
-16
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
+21
-20
services/dbinder/c/include/dbinder_service_inner.h
services/dbinder/c/include/dbinder_service_inner.h
+35
-0
services/dbinder/c/include/dbinder_trans_callback.h
services/dbinder/c/include/dbinder_trans_callback.h
+0
-1
services/dbinder/c/include/dbinder_types.h
services/dbinder/c/include/dbinder_types.h
+18
-0
services/dbinder/c/ipc_adapter/include/dbinder_ipc_adapter.h
services/dbinder/c/ipc_adapter/include/dbinder_ipc_adapter.h
+0
-2
services/dbinder/c/ipc_adapter/mini/dbinder_ipc_adapter.c
services/dbinder/c/ipc_adapter/mini/dbinder_ipc_adapter.c
+8
-15
services/dbinder/c/ipc_adapter/small/dbinder_ipc_adapter.c
services/dbinder/c/ipc_adapter/small/dbinder_ipc_adapter.c
+0
-12
services/dbinder/c/src/dbinder_service.c
services/dbinder/c/src/dbinder_service.c
+54
-22
services/dbinder/c/src/dbinder_stub.c
services/dbinder/c/src/dbinder_stub.c
+4
-2
services/dbinder/c/src/dbinder_trans_callback.c
services/dbinder/c/src/dbinder_trans_callback.c
+1
-1
未找到文件。
interfaces/innerkits/c/dbinder/include/dbinder_service.h
浏览文件 @
aba5a43c
...
@@ -16,44 +16,18 @@
...
@@ -16,44 +16,18 @@
#ifndef DBINDER_SERVICE_H
#ifndef DBINDER_SERVICE_H
#define DBINDER_SERVICE_H
#define DBINDER_SERVICE_H
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include "dbinder_types.h"
#include "utils_list.h"
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#endif
#endif
typedef
struct
{
struct
DHandleEntryHead
head
;
uint32_t
transType
;
uint32_t
dBinderCode
;
uint16_t
fromPort
;
uint16_t
toPort
;
uint64_t
stubIndex
;
uint32_t
seqNumber
;
uintptr_t
binderObject
;
struct
DeviceIdInfo
deviceIdInfo
;
uintptr_t
stub
;
uint16_t
serviceNameLength
;
char
serviceName
[
SERVICENAME_LENGTH
+
1
];
uint32_t
pid
;
uint32_t
uid
;
}
DHandleEntryTxRx
;
int32_t
StartDBinderService
(
void
);
int32_t
StartDBinderService
(
void
);
int32_t
RegisterRemoteProxy
(
const
void
*
name
,
uint32_t
len
,
int32_t
systemAbility
);
int32_t
RegisterRemoteProxy
(
const
void
*
name
,
uint32_t
len
,
int32_t
systemAbility
);
int32_t
MakeRemoteBinder
(
const
void
*
serviceName
,
uint32_t
nameLen
,
const
char
*
deviceID
,
uint32_t
idLen
,
int32_t
MakeRemoteBinder
(
const
void
*
serviceName
,
uint32_t
nameLen
,
const
char
*
deviceID
,
uint32_t
idLen
,
uintptr_t
binderObject
,
uint64_t
pid
,
void
*
remoteObject
);
uintptr_t
binderObject
,
uint64_t
pid
,
void
*
remoteObject
);
int32_t
OnRemoteMessageTask
(
const
DHandleEntryTxRx
*
message
);
SessionInfo
*
QuerySessionObject
(
uintptr_t
stub
);
void
DetachProxyObject
(
ProxyObject
*
proxy
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
...
...
ipc/native/c/manager/include/ipc_process_skeleton.h
浏览文件 @
aba5a43c
...
@@ -72,7 +72,7 @@ int32_t OnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply,
...
@@ -72,7 +72,7 @@ int32_t OnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply,
bool
OnThreadTerminated
(
pthread_t
threadId
);
bool
OnThreadTerminated
(
pthread_t
threadId
);
void
SendObituary
(
DeathCallback
*
deathCallback
);
void
SendObituary
(
DeathCallback
*
deathCallback
);
void
DeleteDeathCallback
(
DeathCallback
*
deathCallback
);
void
DeleteDeathCallback
(
DeathCallback
*
deathCallback
);
void
WaitForProxyInit
(
int32_t
handle
);
void
WaitForProxyInit
(
SvcIdentity
*
svc
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
}
}
...
...
ipc/native/c/manager/include/ipc_thread_pool.h
浏览文件 @
aba5a43c
...
@@ -47,7 +47,7 @@ typedef struct {
...
@@ -47,7 +47,7 @@ typedef struct {
char
callerDeviceID
[
DEVICEID_LENGTH
+
1
];
char
callerDeviceID
[
DEVICEID_LENGTH
+
1
];
bool
stopWorkThread
;
bool
stopWorkThread
;
uint64_t
seqNumber
;
uint64_t
seqNumber
;
uint32_t
clientF
d
;
uint32_t
sessionI
d
;
}
ThreadContext
;
}
ThreadContext
;
typedef
struct
{
typedef
struct
{
...
...
ipc/native/c/manager/src/ipc_process_skeleton.c
浏览文件 @
aba5a43c
...
@@ -270,7 +270,7 @@ static uint32_t SetDeathHandlerPair(DeathCallback *node, uint32_t index, OnRemot
...
@@ -270,7 +270,7 @@ static uint32_t SetDeathHandlerPair(DeathCallback *node, uint32_t index, OnRemot
int32_t
ProcessAddDeathRecipient
(
int32_t
handle
,
OnRemoteDead
deathFunc
,
void
*
args
,
uint32_t
*
cbId
)
int32_t
ProcessAddDeathRecipient
(
int32_t
handle
,
OnRemoteDead
deathFunc
,
void
*
args
,
uint32_t
*
cbId
)
{
{
int32_t
ret
=
ERR_
NONE
;
int32_t
ret
=
ERR_
INVALID_PARAM
;
if
(
g_ipcSkeleton
==
NULL
)
{
if
(
g_ipcSkeleton
==
NULL
)
{
return
ERR_IPC_SKELETON_NOT_INIT
;
return
ERR_IPC_SKELETON_NOT_INIT
;
}
}
...
@@ -419,9 +419,9 @@ void DeleteDeathCallback(DeathCallback *deathCallback)
...
@@ -419,9 +419,9 @@ void DeleteDeathCallback(DeathCallback *deathCallback)
free
(
deathCallback
);
free
(
deathCallback
);
}
}
void
WaitForProxyInit
(
int32_t
handle
)
void
WaitForProxyInit
(
SvcIdentity
*
svc
)
{
{
RPC_LOG_INFO
(
"ipc skeleton wait for proxy init"
);
RPC_LOG_INFO
(
"ipc skeleton wait for proxy init"
);
OnFirstStrongRef
(
handle
);
OnFirstStrongRef
(
svc
->
handle
);
UpdateProtoIfNeed
(
handle
);
UpdateProtoIfNeed
(
svc
);
}
}
\ No newline at end of file
ipc/native/c/manager/src/serializer.c
浏览文件 @
aba5a43c
...
@@ -202,9 +202,9 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc)
...
@@ -202,9 +202,9 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc)
svc
->
handle
=
MIN_BINDER_HANDLE
;
svc
->
handle
=
MIN_BINDER_HANDLE
;
svc
->
cookie
=
obj
->
cookie
;
svc
->
cookie
=
obj
->
cookie
;
}
else
{
}
else
{
WaitForProxyInit
(
obj
->
handle
);
svc
->
handle
=
obj
->
handle
;
svc
->
handle
=
obj
->
handle
;
svc
->
cookie
=
obj
->
cookie
;
svc
->
cookie
=
obj
->
cookie
;
WaitForProxyInit
(
svc
);
}
}
return
true
;
return
true
;
}
}
...
@@ -273,7 +273,7 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc)
...
@@ -273,7 +273,7 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc)
svc
->
handle
=
svcId
->
handle
;
svc
->
handle
=
svcId
->
handle
;
svc
->
token
=
svcId
->
token
;
svc
->
token
=
svcId
->
token
;
svc
->
cookie
=
svcId
->
cookie
;
svc
->
cookie
=
svcId
->
cookie
;
WaitForProxyInit
(
svcId
->
handle
);
WaitForProxyInit
(
svcId
);
return
true
;
return
true
;
}
}
...
...
ipc/native/c/rpc/include/rpc_process_skeleton.h
浏览文件 @
aba5a43c
...
@@ -50,7 +50,7 @@ typedef struct {
...
@@ -50,7 +50,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
UTILS_DL_LIST
list
;
UTILS_DL_LIST
list
;
pthread_t
threadId
;
pthread_t
threadId
;
uint32_t
listenF
d
;
uint32_t
sessionI
d
;
uint32_t
packageSize
;
uint32_t
packageSize
;
char
*
buffer
;
char
*
buffer
;
}
ThreadProcessInfo
;
}
ThreadProcessInfo
;
...
@@ -104,7 +104,7 @@ typedef struct {
...
@@ -104,7 +104,7 @@ typedef struct {
size_t
bufferSize
;
size_t
bufferSize
;
size_t
offsetsSize
;
size_t
offsetsSize
;
uintptr_t
offsets
;
uintptr_t
offsets
;
uint32_t
s
ocket
Id
;
uint32_t
s
ession
Id
;
void
*
buffer
;
void
*
buffer
;
}
ThreadMessageInfo
;
}
ThreadMessageInfo
;
...
@@ -134,7 +134,7 @@ ThreadMessageInfo *QueryThreadBySeqNumber(uint64_t seqNumber);
...
@@ -134,7 +134,7 @@ ThreadMessageInfo *QueryThreadBySeqNumber(uint64_t seqNumber);
void
WakeUpThreadBySeqNumber
(
uint64_t
seqNumber
,
uint32_t
handle
);
void
WakeUpThreadBySeqNumber
(
uint64_t
seqNumber
,
uint32_t
handle
);
int32_t
RpcOnRemoteRequestInner
(
uint32_t
code
,
IpcIo
*
data
,
IpcIo
*
reply
,
int32_t
RpcOnRemoteRequestInner
(
uint32_t
code
,
IpcIo
*
data
,
IpcIo
*
reply
,
MessageOption
option
,
IpcObjectStub
*
objectStub
);
MessageOption
option
,
IpcObjectStub
*
objectStub
);
void
UpdateProtoIfNeed
(
int32_t
handle
);
void
UpdateProtoIfNeed
(
SvcIdentity
*
svc
);
void
WakeUpDataThread
(
pthread_t
threadId
);
void
WakeUpDataThread
(
pthread_t
threadId
);
uint64_t
GetNewStubIndex
(
void
);
uint64_t
GetNewStubIndex
(
void
);
...
...
ipc/native/c/rpc/ipc_adapter/include/ipc_proxy_inner.h
浏览文件 @
aba5a43c
...
@@ -29,7 +29,7 @@ int32_t InvokerListenThread(ProxyObject *proxyObject, const char *localDeviceID,
...
@@ -29,7 +29,7 @@ int32_t InvokerListenThread(ProxyObject *proxyObject, const char *localDeviceID,
const
char
*
remoteDeviceID
,
uint32_t
pid
,
uint32_t
uid
,
IpcIo
*
reply
,
uintptr_t
*
ptr
);
const
char
*
remoteDeviceID
,
uint32_t
pid
,
uint32_t
uid
,
IpcIo
*
reply
,
uintptr_t
*
ptr
);
int32_t
GetPidAndUidInfo
(
ProxyObject
*
proxy
);
int32_t
GetPidAndUidInfo
(
ProxyObject
*
proxy
);
char
*
GetDataBusName
(
void
);
char
*
GetDataBusName
(
void
);
void
UpdateProto
(
int32_t
handle
);
void
UpdateProto
(
SvcIdentity
*
svc
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c
浏览文件 @
aba5a43c
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "rpc_process_skeleton.h"
#include "rpc_process_skeleton.h"
#include "dbinder_invoker.h"
#include "dbinder_invoker.h"
#include "dbinder_types.h"
#include "dbinder_types.h"
#include "dbinder_service_inner.h"
#include "rpc_errno.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "rpc_log.h"
...
@@ -169,12 +170,12 @@ static char *CreateDatabusName(void)
...
@@ -169,12 +170,12 @@ static char *CreateDatabusName(void)
return
sessionName
;
return
sessionName
;
}
}
static
int
GetSessionFromDBinderService
(
uint32_t
handle
)
static
int
GetSessionFromDBinderService
(
SvcIdentity
*
svc
)
{
{
RPC_LOG_INFO
(
"GetSessionFromDBinderService start"
);
RPC_LOG_INFO
(
"GetSessionFromDBinderService start"
);
int32_t
proto
=
IF_PROT_DATABUS
;
int32_t
proto
=
IF_PROT_DATABUS
;
SessionInfo
*
session
=
QuerySessionObject
(
(
uintptr_t
)
handl
e
);
SessionInfo
*
session
=
QuerySessionObject
(
svc
->
cooki
e
);
if
(
session
==
NULL
)
{
if
(
session
==
NULL
)
{
RPC_LOG_ERROR
(
"client find session is null"
);
RPC_LOG_ERROR
(
"client find session is null"
);
return
proto
;
return
proto
;
...
@@ -197,7 +198,7 @@ static int GetSessionFromDBinderService(uint32_t handle)
...
@@ -197,7 +198,7 @@ static int GetSessionFromDBinderService(uint32_t handle)
free
(
sessionObject
);
free
(
sessionObject
);
return
proto
;
return
proto
;
}
}
handleToIndex
->
handle
=
handle
;
handleToIndex
->
handle
=
svc
->
handle
;
handleToIndex
->
index
=
session
->
stubIndex
;
handleToIndex
->
index
=
session
->
stubIndex
;
if
(
AttachHandleToIndex
(
handleToIndex
)
!=
ERR_NONE
)
{
if
(
AttachHandleToIndex
(
handleToIndex
)
!=
ERR_NONE
)
{
...
@@ -216,14 +217,15 @@ static int GetSessionFromDBinderService(uint32_t handle)
...
@@ -216,14 +217,15 @@ static int GetSessionFromDBinderService(uint32_t handle)
return
proto
;
return
proto
;
}
}
UpdateClientSession
(
handle
,
sessionObject
,
localBusName
,
session
->
serviceName
,
session
->
deviceIdInfo
.
toDeviceId
);
UpdateClientSession
(
svc
->
handle
,
sessionObject
,
localBusName
,
session
->
serviceName
,
session
->
deviceIdInfo
.
toDeviceId
);
return
proto
;
return
proto
;
}
}
void
UpdateProto
(
int32_t
handle
)
void
UpdateProto
(
SvcIdentity
*
svc
)
{
{
if
(
handle
<
0
)
{
if
(
svc
->
handle
<
0
)
{
RPC_LOG_ERROR
(
"UpdateProto handle invalid"
);
RPC_LOG_ERROR
(
"UpdateProto handle invalid"
);
return
;
return
;
}
}
...
@@ -233,11 +235,11 @@ void UpdateProto(int32_t handle)
...
@@ -233,11 +235,11 @@ void UpdateProto(int32_t handle)
RPC_LOG_ERROR
(
"UpdateProto threadContext is null"
);
RPC_LOG_ERROR
(
"UpdateProto threadContext is null"
);
return
;
return
;
}
}
HandleSessionList
*
sessionObject
=
QueryProxySession
(
handle
);
HandleSessionList
*
sessionObject
=
QueryProxySession
(
svc
->
handle
);
if
(
sessionObject
!=
NULL
)
{
if
(
sessionObject
!=
NULL
)
{
threadContext
->
proto
=
IF_PROT_DATABUS
;
threadContext
->
proto
=
IF_PROT_DATABUS
;
return
;
return
;
}
}
threadContext
->
proto
=
GetSessionFromDBinderService
(
handle
);
threadContext
->
proto
=
GetSessionFromDBinderService
(
svc
);
RPC_LOG_INFO
(
"UpdateProto get proto: %d"
,
threadContext
->
proto
);
RPC_LOG_INFO
(
"UpdateProto get proto: %d"
,
threadContext
->
proto
);
}
}
\ No newline at end of file
ipc/native/c/rpc/ipc_adapter/small/ipc_proxy_inner.c
浏览文件 @
aba5a43c
...
@@ -225,9 +225,9 @@ char *GetDataBusName(void)
...
@@ -225,9 +225,9 @@ char *GetDataBusName(void)
return
sessionName
;
return
sessionName
;
}
}
void
UpdateProto
(
int32_t
handle
)
void
UpdateProto
(
SvcIdentity
*
svc
)
{
{
if
(
handle
<
0
)
{
if
(
svc
->
handle
<
0
)
{
RPC_LOG_ERROR
(
"UpdateProto handle invalid"
);
RPC_LOG_ERROR
(
"UpdateProto handle invalid"
);
return
;
return
;
}
}
...
@@ -237,11 +237,11 @@ void UpdateProto(int32_t handle)
...
@@ -237,11 +237,11 @@ void UpdateProto(int32_t handle)
RPC_LOG_ERROR
(
"UpdateProto threadContext is null"
);
RPC_LOG_ERROR
(
"UpdateProto threadContext is null"
);
return
;
return
;
}
}
HandleSessionList
*
sessionObject
=
QueryProxySession
(
handle
);
HandleSessionList
*
sessionObject
=
QueryProxySession
(
svc
->
handle
);
if
(
sessionObject
!=
NULL
)
{
if
(
sessionObject
!=
NULL
)
{
threadContext
->
proto
=
IF_PROT_DATABUS
;
threadContext
->
proto
=
IF_PROT_DATABUS
;
return
;
return
;
}
}
threadContext
->
proto
=
GetSessionFromDBinderService
(
handle
);
threadContext
->
proto
=
GetSessionFromDBinderService
(
svc
->
handle
);
RPC_LOG_INFO
(
"UpdateProto get proto: %d"
,
threadContext
->
proto
);
RPC_LOG_INFO
(
"UpdateProto get proto: %d"
,
threadContext
->
proto
);
}
}
\ No newline at end of file
ipc/native/c/rpc/src/dbinder_invoker.c
浏览文件 @
aba5a43c
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "rpc_errno.h"
#include "rpc_errno.h"
#include "rpc_trans.h"
#include "rpc_trans.h"
#include "rpc_trans_callback.h"
#include "rpc_trans_callback.h"
#include "rpc_process_skeleton.h"
#include "ipc_skeleton.h"
#include "ipc_skeleton.h"
#include "ipc_process_skeleton.h"
#include "ipc_process_skeleton.h"
#include "ipc_thread_pool.h"
#include "ipc_thread_pool.h"
...
@@ -46,14 +47,14 @@ void DeleteRpcInvoker(RemoteInvoker *remoteInvoker)
...
@@ -46,14 +47,14 @@ void DeleteRpcInvoker(RemoteInvoker *remoteInvoker)
free
(
remoteInvoker
);
free
(
remoteInvoker
);
}
}
static
HandleSessionList
*
GetSessionObject
(
uint32_t
handle
,
uint32_t
s
ocket
Id
)
static
HandleSessionList
*
GetSessionObject
(
uint32_t
handle
,
uint32_t
s
ession
Id
)
{
{
if
(
handle
!=
0
)
{
if
(
handle
!=
0
)
{
/* transact case */
/* transact case */
return
QueryProxySession
(
handle
);
return
QueryProxySession
(
handle
);
}
else
{
}
else
{
/* reply case */
/* reply case */
return
QueryStubSession
(
s
ocket
Id
);
return
QueryStubSession
(
s
ession
Id
);
}
}
}
}
...
@@ -176,11 +177,11 @@ static int32_t MoveTransData2Buffer(HandleSessionList *sessionObject, dbinder_tr
...
@@ -176,11 +177,11 @@ static int32_t MoveTransData2Buffer(HandleSessionList *sessionObject, dbinder_tr
}
}
static
HandleSessionList
*
WriteTransaction
(
int
cmd
,
MessageOption
option
,
int32_t
handle
,
static
HandleSessionList
*
WriteTransaction
(
int
cmd
,
MessageOption
option
,
int32_t
handle
,
int32_t
s
ocket
Id
,
uint32_t
code
,
IpcIo
*
data
,
uint64_t
*
seqNumber
,
int
status
)
int32_t
s
ession
Id
,
uint32_t
code
,
IpcIo
*
data
,
uint64_t
*
seqNumber
,
int
status
)
{
{
HandleSessionList
*
sessionObject
=
GetSessionObject
(
handle
,
s
ocket
Id
);
HandleSessionList
*
sessionObject
=
GetSessionObject
(
handle
,
s
ession
Id
);
if
(
sessionObject
==
NULL
)
{
if
(
sessionObject
==
NULL
)
{
RPC_LOG_ERROR
(
"session is not exist for
listenFd = %d, handle = %d"
,
socket
Id
,
handle
);
RPC_LOG_ERROR
(
"session is not exist for
sessionId = %d, handle = %d"
,
session
Id
,
handle
);
return
NULL
;
return
NULL
;
}
}
...
@@ -253,7 +254,7 @@ static ThreadMessageInfo *MakeThreadMessageInfo(uint64_t seqNumber, uint32_t han
...
@@ -253,7 +254,7 @@ static ThreadMessageInfo *MakeThreadMessageInfo(uint64_t seqNumber, uint32_t han
messageInfo
->
seqNumber
=
seqNumber
;
messageInfo
->
seqNumber
=
seqNumber
;
messageInfo
->
buffer
=
NULL
;
messageInfo
->
buffer
=
NULL
;
messageInfo
->
offsets
=
0
;
messageInfo
->
offsets
=
0
;
messageInfo
->
s
ocket
Id
=
handle
;
messageInfo
->
s
ession
Id
=
handle
;
return
messageInfo
;
return
messageInfo
;
}
}
...
@@ -329,16 +330,16 @@ static int32_t SendOrWaitForCompletion(int userWaitTime, uint64_t seqNumber,
...
@@ -329,16 +330,16 @@ static int32_t SendOrWaitForCompletion(int userWaitTime, uint64_t seqNumber,
return
WaitForReply
(
seqNumber
,
reply
,
sessionOfPeer
->
handle
,
userWaitTime
,
buffer
);
return
WaitForReply
(
seqNumber
,
reply
,
sessionOfPeer
->
handle
,
userWaitTime
,
buffer
);
}
}
static
int32_t
GetC
lientF
d
(
void
)
static
int32_t
GetC
allerSessionI
d
(
void
)
{
{
ThreadContext
*
threadContext
=
GetCurrentThreadContext
();
ThreadContext
*
threadContext
=
GetCurrentThreadContext
();
return
threadContext
->
clientF
d
;
return
threadContext
->
sessionI
d
;
}
}
static
int32_t
SendReply
(
IpcIo
*
reply
,
uint32_t
flags
,
int32_t
result
)
static
int32_t
SendReply
(
IpcIo
*
reply
,
uint32_t
flags
,
int32_t
result
)
{
{
uint64_t
seqNumber
=
0
;
uint64_t
seqNumber
=
0
;
HandleSessionList
*
sessionObject
=
WriteTransaction
(
BC_REPLY
,
flags
,
0
,
GetC
lientF
d
(),
HandleSessionList
*
sessionObject
=
WriteTransaction
(
BC_REPLY
,
flags
,
0
,
GetC
allerSessionI
d
(),
0
,
reply
,
&
seqNumber
,
result
);
0
,
reply
,
&
seqNumber
,
result
);
if
(
seqNumber
==
0
)
{
if
(
seqNumber
==
0
)
{
...
@@ -349,7 +350,7 @@ static int32_t SendReply(IpcIo *reply, uint32_t flags, int32_t result)
...
@@ -349,7 +350,7 @@ static int32_t SendReply(IpcIo *reply, uint32_t flags, int32_t result)
return
ERR_NONE
;
return
ERR_NONE
;
}
}
static
void
ProcessTransaction
(
const
dbinder_transaction_data
*
tr
,
uint32_t
listenF
d
)
static
void
ProcessTransaction
(
const
dbinder_transaction_data
*
tr
,
uint32_t
sessionI
d
)
{
{
if
(
tr
==
NULL
||
tr
->
cookie
==
0
)
{
if
(
tr
==
NULL
||
tr
->
cookie
==
0
)
{
return
;
return
;
...
@@ -384,10 +385,10 @@ static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t list
...
@@ -384,10 +385,10 @@ static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t list
RPC_LOG_ERROR
(
"stub is invalid, has not OnReceive or Request"
);
RPC_LOG_ERROR
(
"stub is invalid, has not OnReceive or Request"
);
}
}
if
(
!
(
option
&
TF_OP_ASYNC
))
{
if
(
!
(
option
&
TF_OP_ASYNC
))
{
threadContext
->
clientFd
=
listenF
d
;
threadContext
->
sessionId
=
sessionI
d
;
threadContext
->
seqNumber
=
senderSeqNumber
;
threadContext
->
seqNumber
=
senderSeqNumber
;
SendReply
(
&
reply
,
0
,
result
);
SendReply
(
&
reply
,
0
,
result
);
threadContext
->
clientF
d
=
0
;
threadContext
->
sessionI
d
=
0
;
threadContext
->
seqNumber
=
0
;
threadContext
->
seqNumber
=
0
;
}
}
...
@@ -398,7 +399,7 @@ static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t list
...
@@ -398,7 +399,7 @@ static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t list
}
}
}
}
static
void
ProcessReply
(
const
dbinder_transaction_data
*
tr
,
uint32_t
listenF
d
)
static
void
ProcessReply
(
const
dbinder_transaction_data
*
tr
,
uint32_t
sessionI
d
)
{
{
ThreadMessageInfo
*
messageInfo
=
QueryThreadBySeqNumber
(
tr
->
seqNumber
);
ThreadMessageInfo
*
messageInfo
=
QueryThreadBySeqNumber
(
tr
->
seqNumber
);
if
(
messageInfo
==
NULL
)
{
if
(
messageInfo
==
NULL
)
{
...
@@ -412,14 +413,14 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd)
...
@@ -412,14 +413,14 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd)
if
(
messageInfo
->
buffer
==
NULL
)
{
if
(
messageInfo
->
buffer
==
NULL
)
{
RPC_LOG_ERROR
(
"some thread is waiting for reply message, but no memory"
);
RPC_LOG_ERROR
(
"some thread is waiting for reply message, but no memory"
);
/* wake up sender thread */
/* wake up sender thread */
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
listenF
d
);
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
sessionI
d
);
return
;
return
;
}
}
if
(
memcpy_s
(
messageInfo
->
buffer
,
bufferSize
,
tr
->
buffer
,
bufferSize
)
!=
EOK
)
{
if
(
memcpy_s
(
messageInfo
->
buffer
,
bufferSize
,
tr
->
buffer
,
bufferSize
)
!=
EOK
)
{
RPC_LOG_ERROR
(
"messageInfo buffer memset failed"
);
RPC_LOG_ERROR
(
"messageInfo buffer memset failed"
);
free
(
messageInfo
->
buffer
);
free
(
messageInfo
->
buffer
);
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
listenF
d
);
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
sessionI
d
);
return
;
return
;
}
}
...
@@ -427,10 +428,10 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd)
...
@@ -427,10 +428,10 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd)
messageInfo
->
bufferSize
=
tr
->
buffer_size
;
messageInfo
->
bufferSize
=
tr
->
buffer_size
;
messageInfo
->
offsetsSize
=
tr
->
offsets_size
;
messageInfo
->
offsetsSize
=
tr
->
offsets_size
;
messageInfo
->
offsets
=
tr
->
offsets
;
messageInfo
->
offsets
=
tr
->
offsets
;
messageInfo
->
s
ocketId
=
listenF
d
;
messageInfo
->
s
essionId
=
sessionI
d
;
/* wake up sender thread */
/* wake up sender thread */
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
listenF
d
);
WakeUpThreadBySeqNumber
(
tr
->
seqNumber
,
sessionI
d
);
}
}
static
void
OnTransaction
(
ThreadProcessInfo
*
processInfo
)
static
void
OnTransaction
(
ThreadProcessInfo
*
processInfo
)
...
@@ -442,9 +443,9 @@ static void OnTransaction(ThreadProcessInfo *processInfo)
...
@@ -442,9 +443,9 @@ static void OnTransaction(ThreadProcessInfo *processInfo)
tr
->
buffer
=
(
char
*
)(
processInfo
->
buffer
+
sizeof
(
dbinder_transaction_data
));
tr
->
buffer
=
(
char
*
)(
processInfo
->
buffer
+
sizeof
(
dbinder_transaction_data
));
if
(
tr
->
cmd
==
BC_TRANSACTION
)
{
if
(
tr
->
cmd
==
BC_TRANSACTION
)
{
ProcessTransaction
(
tr
,
processInfo
->
listenF
d
);
ProcessTransaction
(
tr
,
processInfo
->
sessionI
d
);
}
else
if
(
tr
->
cmd
==
BC_REPLY
)
{
}
else
if
(
tr
->
cmd
==
BC_REPLY
)
{
ProcessReply
(
tr
,
processInfo
->
listenF
d
);
ProcessReply
(
tr
,
processInfo
->
sessionI
d
);
}
}
}
}
...
@@ -469,7 +470,7 @@ static ThreadProcessInfo *MakeThreadProcessInfo(uint32_t handle, const char *inB
...
@@ -469,7 +470,7 @@ static ThreadProcessInfo *MakeThreadProcessInfo(uint32_t handle, const char *inB
free
(
processInfo
);
free
(
processInfo
);
return
NULL
;
return
NULL
;
}
}
processInfo
->
listenF
d
=
handle
;
processInfo
->
sessionI
d
=
handle
;
processInfo
->
packageSize
=
size
;
processInfo
->
packageSize
=
size
;
return
processInfo
;
return
processInfo
;
...
...
ipc/native/c/rpc/src/rpc_process_skeleton.c
浏览文件 @
aba5a43c
...
@@ -27,8 +27,6 @@
...
@@ -27,8 +27,6 @@
#include "rpc_errno.h"
#include "rpc_errno.h"
#include "rpc_log.h"
#include "rpc_log.h"
#define USECTONSEC 1000
static
RpcSkeleton
g_rpcSkeleton
=
{
static
RpcSkeleton
g_rpcSkeleton
=
{
.
lock
=
PTHREAD_MUTEX_INITIALIZER
,
.
lock
=
PTHREAD_MUTEX_INITIALIZER
,
.
isServerCreated
=
-
1
.
isServerCreated
=
-
1
...
@@ -440,9 +438,9 @@ void WakeUpThreadBySeqNumber(uint64_t seqNumber, uint32_t handle)
...
@@ -440,9 +438,9 @@ void WakeUpThreadBySeqNumber(uint64_t seqNumber, uint32_t handle)
return
;
return
;
}
}
if
(
handle
!=
messageInfo
->
s
ocket
Id
)
{
if
(
handle
!=
messageInfo
->
s
ession
Id
)
{
RPC_LOG_ERROR
(
"error! handle is not equal messageInfo, handle = %d, messageFd = %u"
,
handle
,
RPC_LOG_ERROR
(
"error! handle is not equal messageInfo, handle = %d, messageFd = %u"
,
handle
,
messageInfo
->
s
ocket
Id
);
messageInfo
->
s
ession
Id
);
return
;
return
;
}
}
if
(
pthread_equal
(
messageInfo
->
threadId
,
pthread_self
())
==
0
)
{
if
(
pthread_equal
(
messageInfo
->
threadId
,
pthread_self
())
==
0
)
{
...
@@ -482,10 +480,10 @@ int32_t RpcOnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply, Messag
...
@@ -482,10 +480,10 @@ int32_t RpcOnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply, Messag
return
result
;
return
result
;
}
}
void
UpdateProtoIfNeed
(
int32_t
handle
)
void
UpdateProtoIfNeed
(
SvcIdentity
*
svc
)
{
{
RPC_LOG_INFO
(
"rpc manager update proto, handle %d"
,
handle
);
RPC_LOG_INFO
(
"rpc manager update proto, handle %d"
,
svc
->
handle
);
UpdateProto
(
handle
);
UpdateProto
(
svc
);
}
}
uint64_t
GetNewStubIndex
(
void
)
uint64_t
GetNewStubIndex
(
void
)
...
...
ipc/native/c/rpc/src/rpc_process_skeleton_virtual.c
浏览文件 @
aba5a43c
...
@@ -34,7 +34,7 @@ int32_t RpcOnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply, Messag
...
@@ -34,7 +34,7 @@ int32_t RpcOnRemoteRequestInner(uint32_t code, IpcIo *data, IpcIo *reply, Messag
return
ERR_NOT_RPC
;
return
ERR_NOT_RPC
;
}
}
void
UpdateProtoIfNeed
(
int32_t
handle
)
void
UpdateProtoIfNeed
(
SvcIdentity
*
svc
)
{
{
return
;
return
;
}
}
...
...
ipc/native/c/rpc/trans_adapter/include/rpc_trans.h
浏览文件 @
aba5a43c
...
@@ -34,10 +34,10 @@ typedef struct {
...
@@ -34,10 +34,10 @@ typedef struct {
int32_t
(
*
Connect
)(
const
char
*
SaSessionName
,
const
char
*
peerDeviceId
,
void
*
args
);
int32_t
(
*
Connect
)(
const
char
*
SaSessionName
,
const
char
*
peerDeviceId
,
void
*
args
);
int32_t
(
*
Disconnect
)(
int32_t
sessionId
);
int32_t
(
*
Disconnect
)(
int32_t
sessionId
);
int32_t
(
*
Send
)(
int32_t
sessionId
,
const
void
*
data
,
uint32_t
len
);
int32_t
(
*
Send
)(
int32_t
sessionId
,
const
void
*
data
,
uint32_t
len
);
char
*
(
*
GetLocalDeviceID
)(
void
);
}
TransInterface
;
}
TransInterface
;
TransInterface
*
GetRpcTrans
(
void
);
TransInterface
*
GetRpcTrans
(
void
);
char
*
GetLocalDeviceID
(
void
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
ipc/native/c/rpc/trans_adapter/src/rpc_trans.c
浏览文件 @
aba5a43c
...
@@ -27,14 +27,5 @@ TransInterface *GetRpcTrans(void)
...
@@ -27,14 +27,5 @@ TransInterface *GetRpcTrans(void)
return
GetSocketTrans
();
return
GetSocketTrans
();
#endif
#endif
return
NULL
;
}
char
*
GetLocalDeviceID
(
void
)
{
#if defined(RPC_SOCKET_TRANS)
return
GetSocketLocalDeviceID
();
#endif
return
NULL
;
return
NULL
;
}
}
\ No newline at end of file
ipc/test/rpc/client/rpc_client.c
浏览文件 @
aba5a43c
...
@@ -106,13 +106,8 @@ int main(int argc, char *argv[])
...
@@ -106,13 +106,8 @@ int main(int argc, char *argv[])
return
-
1
;
return
-
1
;
}
}
RPC_LOG_INFO
(
"argv 1 is %s"
,
argv
[
1
]);
if
(
strcmp
(
argv
[
1
],
"deviceId"
)
==
0
)
{
RPC_LOG_INFO
(
"local deviceId is %s"
,
GetLocalDeviceID
());
return
0
;
}
const
char
*
deviceId
=
argv
[
1
];
const
char
*
deviceId
=
argv
[
1
];
RPC_LOG_INFO
(
"input deviceid is %s"
,
deviceId
);
IpcIo
data1
;
IpcIo
data1
;
uint8_t
tmpData1
[
IPC_LENGTH
];
uint8_t
tmpData1
[
IPC_LENGTH
];
...
...
ipc/test/rpc/include/rpc_mini_samgr.h
浏览文件 @
aba5a43c
...
@@ -26,9 +26,9 @@ extern "C" {
...
@@ -26,9 +26,9 @@ extern "C" {
void
RpcStartSamgr
(
void
);
void
RpcStartSamgr
(
void
);
int32_t
AddSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
);
int32_t
AddSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
);
SvcIdentity
*
GetSystemAbilityById
(
int32_t
systemAbilit
y
);
int32_t
GetSystemAbilityById
(
int32_t
systemAbility
,
IpcIo
*
repl
y
);
int32_t
AddRemoteSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
);
int32_t
AddRemoteSystemAbility
(
IpcIo
*
data
);
int32_t
GetRemoteSystemAbility
(
int32_t
saId
,
const
char
*
deviceId
,
SvcIdentity
*
sid
);
int32_t
GetRemoteSystemAbility
(
int32_t
saId
,
const
char
*
deviceId
,
IpcIo
*
reply
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
ipc/test/rpc/samgr/rpc_mini_samgr.c
浏览文件 @
aba5a43c
...
@@ -37,6 +37,14 @@ static UTILS_DL_LIST *g_saList = NULL;
...
@@ -37,6 +37,14 @@ static UTILS_DL_LIST *g_saList = NULL;
static
pthread_mutex_t
g_handleMutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
g_handleMutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
int32_t
g_handle
=
0
;
static
int32_t
g_handle
=
0
;
static
int32_t
GetNextHandle
(
void
)
{
pthread_mutex_lock
(
&
g_handleMutex
);
int32_t
handle
=
++
g_handle
;
pthread_mutex_unlock
(
&
g_handleMutex
);
return
handle
;
}
int32_t
AddSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
)
int32_t
AddSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
)
{
{
RPC_LOG_INFO
(
"AddSystemAbility called.... handle = %d"
,
sid
->
handle
);
RPC_LOG_INFO
(
"AddSystemAbility called.... handle = %d"
,
sid
->
handle
);
...
@@ -59,15 +67,12 @@ int32_t AddSystemAbility(int32_t saId, SvcIdentity *sid)
...
@@ -59,15 +67,12 @@ int32_t AddSystemAbility(int32_t saId, SvcIdentity *sid)
return
ERR_FAILED
;
return
ERR_FAILED
;
}
}
pthread_mutex_lock
(
&
g_handleMutex
);
node
->
sid
->
handle
=
GetNextHandle
();
node
->
sid
->
handle
=
++
g_handle
;
pthread_mutex_unlock
(
&
g_handleMutex
);
UtilsListAdd
(
g_saList
,
&
node
->
list
);
UtilsListAdd
(
g_saList
,
&
node
->
list
);
return
ERR_NONE
;
return
ERR_NONE
;
}
}
SvcIdentity
*
GetSystemAbilityById
(
int32_t
systemAbilit
y
)
int32_t
GetSystemAbilityById
(
int32_t
systemAbility
,
IpcIo
*
repl
y
)
{
{
SvcInfo
*
node
=
NULL
;
SvcInfo
*
node
=
NULL
;
SvcInfo
*
next
=
NULL
;
SvcInfo
*
next
=
NULL
;
...
@@ -75,15 +80,22 @@ SvcIdentity *GetSystemAbilityById(int32_t systemAbility)
...
@@ -75,15 +80,22 @@ SvcIdentity *GetSystemAbilityById(int32_t systemAbility)
{
{
RPC_LOG_INFO
(
"GetSystemAbilityById %d"
,
node
->
saId
);
RPC_LOG_INFO
(
"GetSystemAbilityById %d"
,
node
->
saId
);
if
(
node
->
saId
==
systemAbility
)
{
if
(
node
->
saId
==
systemAbility
)
{
return
node
->
sid
;
WriteRemoteObject
(
reply
,
node
->
sid
);
reply
->
bufferCur
=
reply
->
bufferBase
;
reply
->
offsetsCur
=
reply
->
offsetsCur
;
return
ERR_NONE
;
}
}
}
}
return
NULL
;
return
ERR_FAILED
;
}
}
int32_t
AddRemoteSystemAbility
(
int32_t
saId
,
SvcIdentity
*
sid
)
int32_t
AddRemoteSystemAbility
(
IpcIo
*
data
)
{
{
if
(
AddSystemAbility
(
saId
,
sid
)
==
ERR_FAILED
)
{
int32_t
saId
;
ReadInt32
(
data
,
&
saId
);
SvcIdentity
sid
;
ReadRemoteObject
(
data
,
&
sid
);
if
(
AddSystemAbility
(
saId
,
&
sid
)
==
ERR_FAILED
)
{
RPC_LOG_ERROR
(
"AddSystemAbility failed"
);
RPC_LOG_ERROR
(
"AddSystemAbility failed"
);
return
ERR_FAILED
;
return
ERR_FAILED
;
}
}
...
@@ -97,16 +109,22 @@ int32_t AddRemoteSystemAbility(int32_t saId, SvcIdentity *sid)
...
@@ -97,16 +109,22 @@ int32_t AddRemoteSystemAbility(int32_t saId, SvcIdentity *sid)
return
ERR_NONE
;
return
ERR_NONE
;
}
}
int32_t
GetRemoteSystemAbility
(
int32_t
saId
,
const
char
*
deviceId
,
SvcIdentity
*
sid
)
int32_t
GetRemoteSystemAbility
(
int32_t
saId
,
const
char
*
deviceId
,
IpcIo
*
reply
)
{
{
RPC_LOG_INFO
(
"GetRemoteSystemAbility start"
);
RPC_LOG_INFO
(
"GetRemoteSystemAbility start"
);
const
char
*
name
=
"16"
;
const
char
*
name
=
"16"
;
uint32_t
idLen
=
(
uint32_t
)
strlen
(
deviceId
);
uint32_t
idLen
=
(
uint32_t
)
strlen
(
deviceId
);
int32_t
ret
=
MakeRemoteBinder
(
name
,
2
,
deviceId
,
idLen
,
(
uintptr_t
)
saId
,
0
,
(
void
*
)
sid
);
SvcIdentity
sid
;
int32_t
ret
=
MakeRemoteBinder
(
name
,
2
,
deviceId
,
idLen
,
(
uintptr_t
)
saId
,
0
,
&
sid
);
if
(
ret
!=
ERR_NONE
)
{
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"MakeRemoteBinder failed"
);
RPC_LOG_ERROR
(
"MakeRemoteBinder failed"
);
}
}
sid
.
handle
=
GetNextHandle
();
RPC_LOG_INFO
(
"GetRemoteSystemAbility sid handle=%d"
,
sid
.
handle
);
WriteRemoteObject
(
reply
,
&
sid
);
reply
->
bufferCur
=
reply
->
bufferBase
;
reply
->
offsetsCur
=
reply
->
offsetsBase
;
return
ret
;
return
ret
;
}
}
...
@@ -117,6 +135,11 @@ void RpcStartSamgr(void)
...
@@ -117,6 +135,11 @@ void RpcStartSamgr(void)
g_saList
=
(
UTILS_DL_LIST
*
)
calloc
(
1
,
sizeof
(
UTILS_DL_LIST
));
g_saList
=
(
UTILS_DL_LIST
*
)
calloc
(
1
,
sizeof
(
UTILS_DL_LIST
));
UtilsListInit
(
g_saList
);
UtilsListInit
(
g_saList
);
SvcIdentity
target
=
{
.
cookie
=
0
};
(
void
)
SetContextObject
(
target
);
StartDBinderService
();
StartDBinderService
();
RPC_LOG_INFO
(
"StartDBinderService finished"
);
RPC_LOG_INFO
(
"StartDBinderService finished"
);
...
...
ipc/test/rpc/samgr/rpc_samgr.c
浏览文件 @
aba5a43c
...
@@ -32,6 +32,7 @@ typedef struct {
...
@@ -32,6 +32,7 @@ typedef struct {
static
UTILS_DL_LIST
*
g_saList
=
NULL
;
static
UTILS_DL_LIST
*
g_saList
=
NULL
;
enum
{
enum
{
GET_SYSTEM_ABILITY_TRANSACTION
=
1
,
ADD_SYSTEM_ABILITY_TRANSACTION
=
2
,
ADD_SYSTEM_ABILITY_TRANSACTION
=
2
,
GET_REMOTE_SYSTEM_ABILITY_TRANSACTION
=
3
,
GET_REMOTE_SYSTEM_ABILITY_TRANSACTION
=
3
,
ADD_REMOTE_SYSTEM_ABILITY_TRANSACTION
=
4
,
ADD_REMOTE_SYSTEM_ABILITY_TRANSACTION
=
4
,
...
...
ipc/test/rpc/socket_trans/include/rpc_socket_trans.h
浏览文件 @
aba5a43c
...
@@ -34,7 +34,6 @@ static const uint16_t DEFAULT_HASH_SEED = 5381;
...
@@ -34,7 +34,6 @@ static const uint16_t DEFAULT_HASH_SEED = 5381;
static
const
uint16_t
DEFAULT_PORT_MIN
=
10000
;
static
const
uint16_t
DEFAULT_PORT_MIN
=
10000
;
TransInterface
*
GetSocketTrans
(
void
);
TransInterface
*
GetSocketTrans
(
void
);
char
*
GetSocketLocalDeviceID
(
void
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
ipc/test/rpc/socket_trans/src/rpc_mini_socket_trans.c
浏览文件 @
aba5a43c
...
@@ -353,12 +353,28 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
...
@@ -353,12 +353,28 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
return
ERR_NONE
;
return
ERR_NONE
;
}
}
static
char
*
GetSocketLocalDeviceID
(
void
)
{
extern
struct
netif
if_wifi
;
uint32_t
ip
=
((
ip4_addr_t
*
)
&
if_wifi
.
ip_addr
)
->
addr
;
char
*
localDeviceId
=
inet_ntoa
(
ip
);
if
(
localDeviceId
==
NULL
)
{
RPC_LOG_ERROR
(
"GetSocketLocalDeviceID inet_ntoa return null"
);
return
NULL
;
}
RPC_LOG_INFO
(
"GetSocketLocalDeviceID %s
\n
"
,
localDeviceId
);
return
localDeviceId
;
}
static
TransInterface
g_socketTrans
=
{
static
TransInterface
g_socketTrans
=
{
.
StartListen
=
StartListen
,
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
.
Send
=
Send
,
.
GetLocalDeviceID
=
GetSocketLocalDeviceID
};
};
TransInterface
*
GetSocketTrans
(
void
)
TransInterface
*
GetSocketTrans
(
void
)
...
@@ -371,19 +387,4 @@ TransInterface *GetSocketTrans(void)
...
@@ -371,19 +387,4 @@ TransInterface *GetSocketTrans(void)
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
}
return
&
g_socketTrans
;
return
&
g_socketTrans
;
}
char
*
GetSocketLocalDeviceID
(
void
)
{
extern
struct
netif
if_wifi
;
uint32_t
ip
=
((
ip4_addr_t
*
)
&
if_wifi
.
ip_addr
)
->
addr
;
char
*
localDeviceId
=
inet_ntoa
(
ip
);
if
(
localDeviceId
==
NULL
)
{
RPC_LOG_ERROR
(
"GetSocketLocalDeviceID inet_ntoa return null"
);
return
NULL
;
}
RPC_LOG_INFO
(
"GetSocketLocalDeviceID %s
\n
"
,
localDeviceId
);
return
localDeviceId
;
}
}
\ No newline at end of file
ipc/test/rpc/socket_trans/src/rpc_socket_trans.c
浏览文件 @
aba5a43c
...
@@ -296,26 +296,7 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
...
@@ -296,26 +296,7 @@ static int32_t Send(int32_t sessionId, const void *data, uint32_t len)
return
ERR_NONE
;
return
ERR_NONE
;
}
}
static
TransInterface
g_socketTrans
=
{
static
char
*
GetSocketLocalDeviceID
(
void
)
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
};
TransInterface
*
GetSocketTrans
(
void
)
{
if
(
g_init
==
-
1
)
{
pthread_mutex_lock
(
&
g_socketNodeList
.
mutex
);
UtilsListInit
(
&
g_socketNodeList
.
list
);
g_init
=
0
;
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
return
&
g_socketTrans
;
}
char
*
GetSocketLocalDeviceID
(
void
)
{
{
if
(
g_localDeviceId
!=
NULL
)
{
if
(
g_localDeviceId
!=
NULL
)
{
return
g_localDeviceId
;
return
g_localDeviceId
;
...
@@ -365,4 +346,24 @@ char *GetSocketLocalDeviceID(void)
...
@@ -365,4 +346,24 @@ char *GetSocketLocalDeviceID(void)
freeifaddrs
(
ifaddr
);
freeifaddrs
(
ifaddr
);
return
g_localDeviceId
;
return
g_localDeviceId
;
}
static
TransInterface
g_socketTrans
=
{
.
StartListen
=
StartListen
,
.
StopListen
=
StopListen
,
.
Connect
=
Connect
,
.
Disconnect
=
Disconnect
,
.
Send
=
Send
,
.
GetLocalDeviceID
=
GetSocketLocalDeviceID
,
};
TransInterface
*
GetSocketTrans
(
void
)
{
if
(
g_init
==
-
1
)
{
pthread_mutex_lock
(
&
g_socketNodeList
.
mutex
);
UtilsListInit
(
&
g_socketNodeList
.
list
);
g_init
=
0
;
pthread_mutex_unlock
(
&
g_socketNodeList
.
mutex
);
}
return
&
g_socketTrans
;
}
}
\ No newline at end of file
services/dbinder/c/include/dbinder_service_inner.h
0 → 100644
浏览文件 @
aba5a43c
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DBINDER_SERVICE_INNER_H
#define DBINDER_SERVICE_INNER_H
#include "dbinder_types.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
/* __cplusplus */
int32_t
OnRemoteMessageTask
(
const
DHandleEntryTxRx
*
message
);
SessionInfo
*
QuerySessionObject
(
uintptr_t
stub
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
/* __cplusplus */
#endif
/* DBINDER_SERVICE_INNER_H */
\ No newline at end of file
services/dbinder/c/include/dbinder_trans_callback.h
浏览文件 @
aba5a43c
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include <stdlib.h>
#include "rpc_trans.h"
#include "rpc_trans.h"
#include "dbinder_service.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
services/dbinder/c/include/dbinder_types.h
浏览文件 @
aba5a43c
...
@@ -35,6 +35,7 @@ extern "C" {
...
@@ -35,6 +35,7 @@ extern "C" {
#define GET_SYSTEM_ABILITY_TRANSACTION 1
#define GET_SYSTEM_ABILITY_TRANSACTION 1
#define ID_DIGITS 10
#define ID_DIGITS 10
#define DEFAULT_SEND_WAIT_TIME 4
#define DEFAULT_SEND_WAIT_TIME 4
#define USECTONSEC 1000
enum
DBinderCode
{
enum
DBinderCode
{
MESSAGE_AS_INVOKER
=
1
,
MESSAGE_AS_INVOKER
=
1
,
...
@@ -99,6 +100,23 @@ typedef struct {
...
@@ -99,6 +100,23 @@ typedef struct {
char
*
buffer
;
char
*
buffer
;
}
dbinder_transaction_data
;
}
dbinder_transaction_data
;
typedef
struct
{
struct
DHandleEntryHead
head
;
uint32_t
transType
;
uint32_t
dBinderCode
;
uint16_t
fromPort
;
uint16_t
toPort
;
uint64_t
stubIndex
;
uint32_t
seqNumber
;
uintptr_t
binderObject
;
struct
DeviceIdInfo
deviceIdInfo
;
uintptr_t
stub
;
uint16_t
serviceNameLength
;
char
serviceName
[
SERVICENAME_LENGTH
+
1
];
uint32_t
pid
;
uint32_t
uid
;
}
DHandleEntryTxRx
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
services/dbinder/c/ipc_adapter/include/dbinder_ipc_adapter.h
浏览文件 @
aba5a43c
...
@@ -28,8 +28,6 @@ extern "C" {
...
@@ -28,8 +28,6 @@ extern "C" {
bool
IsSameStub
(
DBinderServiceStub
*
stub
,
const
char
*
serviceName
,
bool
IsSameStub
(
DBinderServiceStub
*
stub
,
const
char
*
serviceName
,
const
char
*
deviceID
,
uintptr_t
binderObject
);
const
char
*
deviceID
,
uintptr_t
binderObject
);
int32_t
GetDBinderHandle
(
uintptr_t
stubAddr
);
int32_t
UpdateSessionIfNeed
(
uintptr_t
stubAddr
);
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
);
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
services/dbinder/c/ipc_adapter/mini/dbinder_ipc_adapter.c
浏览文件 @
aba5a43c
...
@@ -28,24 +28,17 @@ bool IsSameStub(DBinderServiceStub *stub, const char *serviceName,
...
@@ -28,24 +28,17 @@ bool IsSameStub(DBinderServiceStub *stub, const char *serviceName,
return
false
;
return
false
;
}
}
int32_t
GetDBinderHandle
(
uintptr_t
stubAddr
)
{
return
(
int32_t
)
stubAddr
;
}
int32_t
UpdateSessionIfNeed
(
uintptr_t
stubAddr
)
{
UpdateProto
((
int32_t
)
stubAddr
);
return
ERR_NONE
;
}
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
)
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
)
{
{
SvcIdentity
*
target
=
GetSystemAbilityById
(
systemAbility
);
IpcIo
reply
;
if
(
target
==
NULL
)
{
uint8_t
replyAlloc
[
RPC_IPC_LENGTH
];
RPC_LOG_ERROR
(
"GetSystemAbilityById return null"
);
IpcIoInit
(
&
reply
,
replyAlloc
,
RPC_IPC_LENGTH
,
0
);
if
(
GetSystemAbilityById
(
systemAbility
,
&
reply
)
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"GetSystemAbilityById failed"
);
return
NULL
;
return
NULL
;
}
}
SvcIdentity
target
;
ReadRemoteObject
(
&
reply
,
&
target
);
ProxyObject
*
proxyObject
=
(
ProxyObject
*
)
calloc
(
1
,
sizeof
(
ProxyObject
));
ProxyObject
*
proxyObject
=
(
ProxyObject
*
)
calloc
(
1
,
sizeof
(
ProxyObject
));
if
(
proxyObject
==
NULL
)
{
if
(
proxyObject
==
NULL
)
{
...
@@ -57,7 +50,7 @@ ProxyObject *RpcGetSystemAbility(int32_t systemAbility)
...
@@ -57,7 +50,7 @@ ProxyObject *RpcGetSystemAbility(int32_t systemAbility)
return
NULL
;
return
NULL
;
}
}
if
(
memcpy_s
(
proxyObject
->
proxy
,
sizeof
(
SvcIdentity
),
target
,
sizeof
(
SvcIdentity
))
!=
EOK
)
{
if
(
memcpy_s
(
proxyObject
->
proxy
,
sizeof
(
SvcIdentity
),
&
target
,
sizeof
(
SvcIdentity
))
!=
EOK
)
{
free
(
proxyObject
->
proxy
);
free
(
proxyObject
->
proxy
);
free
(
proxyObject
);
free
(
proxyObject
);
return
NULL
;
return
NULL
;
...
...
services/dbinder/c/ipc_adapter/small/dbinder_ipc_adapter.c
浏览文件 @
aba5a43c
...
@@ -23,8 +23,6 @@
...
@@ -23,8 +23,6 @@
#include "rpc_log.h"
#include "rpc_log.h"
#include "rpc_errno.h"
#include "rpc_errno.h"
#define IPC_STUB_HANDLE (-1)
bool
IsSameStub
(
DBinderServiceStub
*
stub
,
const
char
*
serviceName
,
bool
IsSameStub
(
DBinderServiceStub
*
stub
,
const
char
*
serviceName
,
const
char
*
deviceID
,
uintptr_t
binderObject
)
const
char
*
deviceID
,
uintptr_t
binderObject
)
{
{
...
@@ -35,16 +33,6 @@ bool IsSameStub(DBinderServiceStub *stub, const char *serviceName,
...
@@ -35,16 +33,6 @@ bool IsSameStub(DBinderServiceStub *stub, const char *serviceName,
&&
stub
->
binderObject
==
binderObject
);
&&
stub
->
binderObject
==
binderObject
);
}
}
int32_t
GetDBinderHandle
(
uintptr_t
stubAddr
)
{
return
IPC_STUB_HANDLE
;
}
int32_t
UpdateSessionIfNeed
(
uintptr_t
stubAddr
)
{
return
ERR_NONE
;
}
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
)
ProxyObject
*
RpcGetSystemAbility
(
int32_t
systemAbility
)
{
{
IpcIo
data
;
IpcIo
data
;
...
...
services/dbinder/c/src/dbinder_service.c
浏览文件 @
aba5a43c
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <stdbool.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdlib.h>
#include <pthread.h>
#include <pthread.h>
#include <sys/time.h>
#include "utils_list.h"
#include "utils_list.h"
#include "securec.h"
#include "securec.h"
...
@@ -27,6 +28,7 @@
...
@@ -27,6 +28,7 @@
#include "rpc_trans.h"
#include "rpc_trans.h"
#include "dbinder_trans_callback.h"
#include "dbinder_trans_callback.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_service_inner.h"
#include "serializer.h"
#include "serializer.h"
#include "dbinder_stub.h"
#include "dbinder_stub.h"
#include "ipc_skeleton.h"
#include "ipc_skeleton.h"
...
@@ -214,7 +216,7 @@ static int32_t SendEntryToRemote(DBinderServiceStub *stub, const uint32_t seqNum
...
@@ -214,7 +216,7 @@ static int32_t SendEntryToRemote(DBinderServiceStub *stub, const uint32_t seqNum
}
}
uint32_t
toDeviceIDLength
=
(
uint32_t
)
strlen
(
toDeviceID
);
uint32_t
toDeviceIDLength
=
(
uint32_t
)
strlen
(
toDeviceID
);
char
*
localDeviceID
=
GetLocalDeviceID
();
char
*
localDeviceID
=
g_trans
->
GetLocalDeviceID
();
if
(
localDeviceID
==
NULL
)
{
if
(
localDeviceID
==
NULL
)
{
RPC_LOG_ERROR
(
"GetLocalDeviceID failed"
);
RPC_LOG_ERROR
(
"GetLocalDeviceID failed"
);
return
ERR_FAILED
;
return
ERR_FAILED
;
...
@@ -270,37 +272,56 @@ static void DetachThreadLockInfo(ThreadLockInfo *threadLockInfo)
...
@@ -270,37 +272,56 @@ static void DetachThreadLockInfo(ThreadLockInfo *threadLockInfo)
pthread_mutex_unlock
(
&
g_threadLockInfoList
.
mutex
);
pthread_mutex_unlock
(
&
g_threadLockInfoList
.
mutex
);
}
}
static
int32_t
InvokerRemoteDBinder
(
DBinderServiceStub
*
dBinderServiceStub
,
uint32_t
seqNumber
)
static
ThreadLockInfo
*
NewThreadLock
(
void
)
{
{
if
(
dBinderServiceStub
==
NULL
)
{
RPC_LOG_ERROR
(
"InvokerRemoteDBinder dBinderServiceStub is NULL"
);
return
ERR_FAILED
;
}
int32_t
ret
=
ERR_FAILED
;
ThreadLockInfo
*
threadLockInfo
=
(
ThreadLockInfo
*
)
malloc
(
sizeof
(
ThreadLockInfo
));
ThreadLockInfo
*
threadLockInfo
=
(
ThreadLockInfo
*
)
malloc
(
sizeof
(
ThreadLockInfo
));
if
(
threadLockInfo
==
NULL
)
{
if
(
threadLockInfo
==
NULL
)
{
RPC_LOG_ERROR
(
"threadLockInfo malloc failed"
);
RPC_LOG_ERROR
(
"threadLockInfo malloc failed"
);
return
ERR_FAILED
;
return
NULL
;
}
}
if
(
pthread_mutex_init
(
&
threadLockInfo
->
mutex
,
NULL
)
!=
0
)
{
if
(
pthread_mutex_init
(
&
threadLockInfo
->
mutex
,
NULL
)
!=
0
)
{
RPC_LOG_ERROR
(
"threadLockInfo mutex init failed"
);
RPC_LOG_ERROR
(
"threadLockInfo mutex init failed"
);
free
(
threadLockInfo
);
free
(
threadLockInfo
);
return
ERR_FAILED
;
return
NULL
;
}
}
if
(
pthread_cond_init
(
&
threadLockInfo
->
condition
,
NULL
)
!=
0
)
{
if
(
pthread_cond_init
(
&
threadLockInfo
->
condition
,
NULL
)
!=
0
)
{
RPC_LOG_ERROR
(
"threadLockInfo condition init failed"
);
RPC_LOG_ERROR
(
"threadLockInfo condition init failed"
);
pthread_mutex_destroy
(
&
threadLockInfo
->
mutex
);
free
(
threadLockInfo
);
free
(
threadLockInfo
);
return
NULL
;
}
return
threadLockInfo
;
}
static
int32_t
GetWaitTime
(
struct
timespec
*
waitTime
)
{
struct
timeval
now
;
if
(
gettimeofday
(
&
now
,
NULL
)
!=
0
)
{
RPC_LOG_ERROR
(
"gettimeofday failed"
);
return
ERR_FAILED
;
return
ERR_FAILED
;
}
}
waitTime
->
tv_sec
=
now
.
tv_sec
+
DEFAULT_SEND_WAIT_TIME
;
waitTime
->
tv_nsec
=
now
.
tv_usec
*
USECTONSEC
;
return
ERR_NONE
;
}
static
int32_t
InvokerRemoteDBinder
(
DBinderServiceStub
*
dBinderServiceStub
,
uint32_t
seqNumber
)
{
if
(
dBinderServiceStub
==
NULL
)
{
RPC_LOG_ERROR
(
"InvokerRemoteDBinder dBinderServiceStub is NULL"
);
return
ERR_FAILED
;
}
int32_t
ret
=
ERR_FAILED
;
ThreadLockInfo
*
threadLockInfo
=
NewThreadLock
();
if
(
threadLockInfo
==
NULL
)
{
return
ret
;
}
threadLockInfo
->
seqNumber
=
seqNumber
;
threadLockInfo
->
seqNumber
=
seqNumber
;
ret
=
AttachThreadLockInfo
(
threadLockInfo
);
ret
=
AttachThreadLockInfo
(
threadLockInfo
);
if
(
ret
!=
ERR_NONE
)
{
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"AttachThreadLockInfo failed"
);
RPC_LOG_ERROR
(
"AttachThreadLockInfo failed"
);
pthread_mutex_destroy
(
&
threadLockInfo
->
mutex
);
pthread_cond_destroy
(
&
threadLockInfo
->
condition
);
free
(
threadLockInfo
);
free
(
threadLockInfo
);
return
ret
;
return
ret
;
}
}
...
@@ -310,7 +331,23 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
...
@@ -310,7 +331,23 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
if
(
ret
!=
ERR_NONE
)
{
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"send entry to remote dbinderService failed"
);
RPC_LOG_ERROR
(
"send entry to remote dbinderService failed"
);
}
else
{
}
else
{
pthread_cond_wait
(
&
threadLockInfo
->
condition
,
&
threadLockInfo
->
mutex
);
struct
timespec
waitTime
;
ret
=
GetWaitTime
(
&
waitTime
);
if
(
ret
!=
ERR_NONE
)
{
DetachThreadLockInfo
(
threadLockInfo
);
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
free
(
threadLockInfo
);
return
ERR_FAILED
;
}
ret
=
pthread_cond_timedwait
(
&
threadLockInfo
->
condition
,
&
threadLockInfo
->
mutex
,
&
waitTime
);
if
(
ret
==
ETIMEDOUT
)
{
RPC_LOG_ERROR
(
"InvokerRemoteDBinder wait for reply timeout"
);
DetachThreadLockInfo
(
threadLockInfo
);
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
free
(
threadLockInfo
);
return
ERR_FAILED
;
}
RPC_LOG_INFO
(
"InvokerRemoteDBinder wakeup!"
);
RPC_LOG_INFO
(
"InvokerRemoteDBinder wakeup!"
);
}
}
...
@@ -319,13 +356,8 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
...
@@ -319,13 +356,8 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
ret
=
ERR_FAILED
;
ret
=
ERR_FAILED
;
}
}
if
(
UpdateSessionIfNeed
(
dBinderServiceStub
->
svc
.
cookie
)
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"UpdateSessionIfNeed failed"
);
ret
=
ERR_FAILED
;
}
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
DetachThreadLockInfo
(
threadLockInfo
);
DetachThreadLockInfo
(
threadLockInfo
);
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
free
(
threadLockInfo
);
free
(
threadLockInfo
);
return
ret
;
return
ret
;
...
@@ -405,7 +437,7 @@ static int32_t AttachProxyObject(ProxyObject *proxy)
...
@@ -405,7 +437,7 @@ static int32_t AttachProxyObject(ProxyObject *proxy)
return
ERR_NONE
;
return
ERR_NONE
;
}
}
void
DetachProxyObject
(
ProxyObject
*
proxy
)
static
void
DetachProxyObject
(
ProxyObject
*
proxy
)
{
{
pthread_mutex_lock
(
&
g_proxyObjectList
.
mutex
);
pthread_mutex_lock
(
&
g_proxyObjectList
.
mutex
);
UtilsListDelete
(
&
proxy
->
list
);
UtilsListDelete
(
&
proxy
->
list
);
...
@@ -501,7 +533,7 @@ static int32_t OnRemoteInvokerDataBusMessage(ProxyObject *proxy, DHandleEntryTxR
...
@@ -501,7 +533,7 @@ static int32_t OnRemoteInvokerDataBusMessage(ProxyObject *proxy, DHandleEntryTxR
IpcIo
reply
;
IpcIo
reply
;
uintptr_t
ptr
;
uintptr_t
ptr
;
int32_t
ret
=
InvokerListenThread
(
proxy
,
GetLocalDeviceID
(),
remoteDeviceID
,
pid
,
uid
,
&
reply
,
&
ptr
);
int32_t
ret
=
InvokerListenThread
(
proxy
,
g_trans
->
GetLocalDeviceID
(),
remoteDeviceID
,
pid
,
uid
,
&
reply
,
&
ptr
);
if
(
ret
!=
ERR_NONE
)
{
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"INVOKE_LISTEN_THREAD failed"
);
RPC_LOG_ERROR
(
"INVOKE_LISTEN_THREAD failed"
);
FreeBuffer
((
void
*
)
ptr
);
FreeBuffer
((
void
*
)
ptr
);
...
...
services/dbinder/c/src/dbinder_stub.c
浏览文件 @
aba5a43c
...
@@ -24,8 +24,10 @@
...
@@ -24,8 +24,10 @@
#include "ipc_thread_pool.h"
#include "ipc_thread_pool.h"
#include "ipc_skeleton.h"
#include "ipc_skeleton.h"
#include "ipc_process_skeleton.h"
#include "ipc_process_skeleton.h"
#include "dbinder_service.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_ipc_adapter.h"
#include "dbinder_service_inner.h"
#define IPC_INVALID_HANDLE (-1)
static
int32_t
GetDigits
(
int32_t
number
)
static
int32_t
GetDigits
(
int32_t
number
)
{
{
...
@@ -135,7 +137,7 @@ int32_t GetDBinderStub(const char *serviceName, const char *deviceID,
...
@@ -135,7 +137,7 @@ int32_t GetDBinderStub(const char *serviceName, const char *deviceID,
objectStub
->
isRemote
=
true
;
objectStub
->
isRemote
=
true
;
dBinderServiceStub
->
binderObject
=
binderObject
;
dBinderServiceStub
->
binderObject
=
binderObject
;
dBinderServiceStub
->
svc
.
handle
=
GetDBinderHandle
((
uintptr_t
)
objectStub
)
;
dBinderServiceStub
->
svc
.
handle
=
IPC_INVALID_HANDLE
;
dBinderServiceStub
->
svc
.
token
=
(
uintptr_t
)
objectStub
;
dBinderServiceStub
->
svc
.
token
=
(
uintptr_t
)
objectStub
;
dBinderServiceStub
->
svc
.
cookie
=
(
uintptr_t
)
objectStub
;
dBinderServiceStub
->
svc
.
cookie
=
(
uintptr_t
)
objectStub
;
return
ERR_NONE
;
return
ERR_NONE
;
...
...
services/dbinder/c/src/dbinder_trans_callback.c
浏览文件 @
aba5a43c
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#include <stdbool.h>
#include <stdbool.h>
#include "dbinder_service.h"
#include "dbinder_service
_inner
.h"
#include "rpc_log.h"
#include "rpc_log.h"
#include "rpc_errno.h"
#include "rpc_errno.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录