Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
communication_ipc
提交
97da4435
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,发现更多精彩内容 >>
提交
97da4435
编写于
1月 18, 2022
作者:
Y
yangguangzhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add timeout mechanism when MakeRemoteBinder
Signed-off-by:
N
yangguangzhao
<
yangguangzhao1@huawei.com
>
上级
c1970b93
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
16 deletion
+51
-16
ipc/native/c/rpc/src/rpc_process_skeleton.c
ipc/native/c/rpc/src/rpc_process_skeleton.c
+0
-2
services/dbinder/c/include/dbinder_types.h
services/dbinder/c/include/dbinder_types.h
+1
-0
services/dbinder/c/src/dbinder_service.c
services/dbinder/c/src/dbinder_service.c
+50
-14
未找到文件。
ipc/native/c/rpc/src/rpc_process_skeleton.c
浏览文件 @
97da4435
...
...
@@ -27,8 +27,6 @@
#include "rpc_errno.h"
#include "rpc_log.h"
#define USECTONSEC 1000
static
RpcSkeleton
g_rpcSkeleton
=
{
.
lock
=
PTHREAD_MUTEX_INITIALIZER
,
.
isServerCreated
=
-
1
...
...
services/dbinder/c/include/dbinder_types.h
浏览文件 @
97da4435
...
...
@@ -35,6 +35,7 @@ extern "C" {
#define GET_SYSTEM_ABILITY_TRANSACTION 1
#define ID_DIGITS 10
#define DEFAULT_SEND_WAIT_TIME 4
#define USECTONSEC 1000
enum
DBinderCode
{
MESSAGE_AS_INVOKER
=
1
,
...
...
services/dbinder/c/src/dbinder_service.c
浏览文件 @
97da4435
...
...
@@ -20,6 +20,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/time.h>
#include "utils_list.h"
#include "securec.h"
...
...
@@ -271,37 +272,56 @@ static void DetachThreadLockInfo(ThreadLockInfo *threadLockInfo)
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
));
if
(
threadLockInfo
==
NULL
)
{
RPC_LOG_ERROR
(
"threadLockInfo malloc failed"
);
return
ERR_FAILED
;
return
NULL
;
}
if
(
pthread_mutex_init
(
&
threadLockInfo
->
mutex
,
NULL
)
!=
0
)
{
RPC_LOG_ERROR
(
"threadLockInfo mutex init failed"
);
free
(
threadLockInfo
);
return
ERR_FAILED
;
return
NULL
;
}
if
(
pthread_cond_init
(
&
threadLockInfo
->
condition
,
NULL
)
!=
0
)
{
RPC_LOG_ERROR
(
"threadLockInfo condition init failed"
);
pthread_mutex_destroy
(
&
threadLockInfo
->
mutex
);
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
;
}
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
;
ret
=
AttachThreadLockInfo
(
threadLockInfo
);
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"AttachThreadLockInfo failed"
);
pthread_mutex_destroy
(
&
threadLockInfo
->
mutex
);
pthread_cond_destroy
(
&
threadLockInfo
->
condition
);
free
(
threadLockInfo
);
return
ret
;
}
...
...
@@ -311,7 +331,23 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
if
(
ret
!=
ERR_NONE
)
{
RPC_LOG_ERROR
(
"send entry to remote dbinderService failed"
);
}
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!"
);
}
...
...
@@ -320,8 +356,8 @@ static int32_t InvokerRemoteDBinder(DBinderServiceStub *dBinderServiceStub, uint
ret
=
ERR_FAILED
;
}
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
DetachThreadLockInfo
(
threadLockInfo
);
pthread_mutex_unlock
(
&
threadLockInfo
->
mutex
);
free
(
threadLockInfo
);
return
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录