未验证 提交 8eab142b 编写于 作者: O openharmony_ci 提交者: Gitee

!224 IPC:optimize interfaces GetCallingPid/Uid & ipc process skeleton deinitialization logic

Merge pull request !224 from liubb_0516/master
......@@ -25,7 +25,7 @@ extern "C" {
#endif /* __cplusplus */
RemoteInvoker *GetIpcInvoker(void);
void DeinitIpcInvoker(RemoteInvoker *invoker);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -91,10 +91,12 @@ static void DeleteBinderConnector(void)
if (g_connector == NULL) {
return;
}
pthread_mutex_lock(&g_connectorMutex);
munmap(g_connector->mmapAddr, g_connector->mmapSize);
close(g_connector->fd);
free(g_connector);
g_connector = NULL;
pthread_mutex_unlock(&g_connectorMutex);
}
static int32_t BinderWrite(void *data, size_t len)
......@@ -564,3 +566,11 @@ RemoteInvoker *GetIpcInvoker(void)
}
return &g_ipcInvoker;
}
void DeinitIpcInvoker(RemoteInvoker *invoker)
{
if (invoker != &g_ipcInvoker) {
return;
}
DeleteBinderConnector();
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ typedef struct {
} RemoteInvoker;
RemoteInvoker *InitRemoteInvoker(int32_t proto);
void DeinitRemoteInvoker(RemoteInvoker *invoker, int32_t proto);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -132,18 +132,22 @@ void JoinMainWorkThread(void)
pid_t ProcessGetCallingPid(void)
{
ThreadContext *currentContext = GetCurrentThreadContext();
if (currentContext != NULL) {
return currentContext->callerPid;
if (g_ipcSkeleton != NULL) {
ThreadContext *currentContext = GetCurrentThreadContext();
if (currentContext != NULL) {
return currentContext->callerPid;
}
}
return RpcGetPid();
}
pid_t ProcessGetCallingUid(void)
{
ThreadContext *currentContext = GetCurrentThreadContext();
if (currentContext != NULL) {
return currentContext->callerUid;
if (g_ipcSkeleton != NULL) {
ThreadContext *currentContext = GetCurrentThreadContext();
if (currentContext != NULL) {
return currentContext->callerUid;
}
}
return RpcGetUid();
}
......
......@@ -48,19 +48,11 @@ void JoinWorkThread(void)
pid_t GetCallingPid(void)
{
if (GetCurrentSkeleton() == NULL) {
RPC_LOG_ERROR("init ipc process skeleton failed.");
return ERR_IPC_SKELETON_NOT_INIT;
}
return ProcessGetCallingPid();
}
pid_t GetCallingUid(void)
{
if (GetCurrentSkeleton() == NULL) {
RPC_LOG_ERROR("init ipc process skeleton failed.");
return ERR_IPC_SKELETON_NOT_INIT;
}
return ProcessGetCallingUid();
}
......
......@@ -133,6 +133,7 @@ void DeinitThreadPool(ThreadPool *threadPool)
pthread_key_delete(g_localKey);
free(threadPool);
for (int32_t index = 0; index < PROTO_NUM; ++index) {
DeinitRemoteInvoker(g_invoker[index], index);
g_invoker[index] = NULL;
}
}
......
......@@ -28,4 +28,14 @@ RemoteInvoker *InitRemoteInvoker(int32_t proto)
remoteInvoker = GetRpcInvoker();
}
return remoteInvoker;
}
void DeinitRemoteInvoker(RemoteInvoker *invoker, int32_t proto)
{
if (invoker == NULL) {
return;
}
if (proto == IF_PROT_BINDER) {
DeinitIpcInvoker(invoker);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册