diff --git a/ipc/native/c/manager/include/ipc_thread_pool.h b/ipc/native/c/manager/include/ipc_thread_pool.h index 90cffecf56d40b588c5f16d66ce5e73c1a0759da..066cfd6c4389628f2d2479c1f6f875edbb0a308a 100644 --- a/ipc/native/c/manager/include/ipc_thread_pool.h +++ b/ipc/native/c/manager/include/ipc_thread_pool.h @@ -47,7 +47,7 @@ typedef struct { char callerDeviceID[DEVICEID_LENGTH + 1]; bool stopWorkThread; uint64_t seqNumber; - uint32_t clientFd; + uint32_t sessionId; } ThreadContext; typedef struct { diff --git a/ipc/native/c/manager/src/serializer.c b/ipc/native/c/manager/src/serializer.c index 1ea24e7a66480ebbf74466a5545b220975dd0b31..815563f64337353c18fac78f7b012412a05e88b0 100644 --- a/ipc/native/c/manager/src/serializer.c +++ b/ipc/native/c/manager/src/serializer.c @@ -202,9 +202,9 @@ bool ReadRemoteObject(IpcIo *io, SvcIdentity *svc) svc->handle = MIN_BINDER_HANDLE; svc->cookie = obj->cookie; } else { - WaitForProxyInit(obj); svc->handle = obj->handle; svc->cookie = obj->cookie; + WaitForProxyInit(svc); } return true; } diff --git a/ipc/native/c/rpc/include/rpc_process_skeleton.h b/ipc/native/c/rpc/include/rpc_process_skeleton.h index 883a2169033ec7b64ef9796f6ad303b33740e5c0..079c9b659da222c530cb537934bda4fec13dd676 100644 --- a/ipc/native/c/rpc/include/rpc_process_skeleton.h +++ b/ipc/native/c/rpc/include/rpc_process_skeleton.h @@ -50,7 +50,7 @@ typedef struct { typedef struct { UTILS_DL_LIST list; pthread_t threadId; - uint32_t listenFd; + uint32_t sessionId; uint32_t packageSize; char *buffer; } ThreadProcessInfo; @@ -104,7 +104,7 @@ typedef struct { size_t bufferSize; size_t offsetsSize; uintptr_t offsets; - uint32_t socketId; + uint32_t sessionId; void *buffer; } ThreadMessageInfo; diff --git a/ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c b/ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c index e5910515fef1e54823e3a56047457662da8d889c..458629fe3803581e1542d0bb9443542584b273dc 100644 --- a/ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c +++ b/ipc/native/c/rpc/ipc_adapter/mini/ipc_proxy_inner.c @@ -217,7 +217,8 @@ static int GetSessionFromDBinderService(SvcIdentity *svc) return proto; } - UpdateClientSession(svc->handle, sessionObject, localBusName, session->serviceName, session->deviceIdInfo.toDeviceId); + UpdateClientSession(svc->handle, sessionObject, localBusName, + session->serviceName, session->deviceIdInfo.toDeviceId); return proto; } diff --git a/ipc/native/c/rpc/src/dbinder_invoker.c b/ipc/native/c/rpc/src/dbinder_invoker.c index e9ca459100f9f535ebd6fda95c492c5a0a5279ac..fa3b77b2ca0e069dc448443f8c9f2dc2a397e435 100644 --- a/ipc/native/c/rpc/src/dbinder_invoker.c +++ b/ipc/native/c/rpc/src/dbinder_invoker.c @@ -26,6 +26,7 @@ #include "rpc_errno.h" #include "rpc_trans.h" #include "rpc_trans_callback.h" +#include "rpc_process_skeleton.h" #include "ipc_skeleton.h" #include "ipc_process_skeleton.h" #include "ipc_thread_pool.h" @@ -46,14 +47,14 @@ void DeleteRpcInvoker(RemoteInvoker *remoteInvoker) free(remoteInvoker); } -static HandleSessionList *GetSessionObject(uint32_t handle, uint32_t socketId) +static HandleSessionList *GetSessionObject(uint32_t handle, uint32_t sessionId) { if (handle != 0) { /* transact case */ return QueryProxySession(handle); } else { /* reply case */ - return QueryStubSession(socketId); + return QueryStubSession(sessionId); } } @@ -176,11 +177,11 @@ static int32_t MoveTransData2Buffer(HandleSessionList *sessionObject, dbinder_tr } static HandleSessionList *WriteTransaction(int cmd, MessageOption option, int32_t handle, - int32_t socketId, uint32_t code, IpcIo *data, uint64_t *seqNumber, int status) + int32_t sessionId, uint32_t code, IpcIo *data, uint64_t *seqNumber, int status) { - HandleSessionList *sessionObject = GetSessionObject(handle, socketId); + HandleSessionList *sessionObject = GetSessionObject(handle, sessionId); if (sessionObject == NULL) { - RPC_LOG_ERROR("session is not exist for listenFd = %d, handle = %d", socketId, handle); + RPC_LOG_ERROR("session is not exist for sessionId = %d, handle = %d", sessionId, handle); return NULL; } @@ -253,7 +254,7 @@ static ThreadMessageInfo *MakeThreadMessageInfo(uint64_t seqNumber, uint32_t han messageInfo->seqNumber = seqNumber; messageInfo->buffer = NULL; messageInfo->offsets = 0; - messageInfo->socketId = handle; + messageInfo->sessionId = handle; return messageInfo; } @@ -329,16 +330,16 @@ static int32_t SendOrWaitForCompletion(int userWaitTime, uint64_t seqNumber, return WaitForReply(seqNumber, reply, sessionOfPeer->handle, userWaitTime, buffer); } -static int32_t GetClientFd(void) +static int32_t GetCallerSessionId(void) { ThreadContext *threadContext = GetCurrentThreadContext(); - return threadContext->clientFd; + return threadContext->sessionId; } static int32_t SendReply(IpcIo *reply, uint32_t flags, int32_t result) { uint64_t seqNumber = 0; - HandleSessionList *sessionObject = WriteTransaction(BC_REPLY, flags, 0, GetClientFd(), + HandleSessionList *sessionObject = WriteTransaction(BC_REPLY, flags, 0, GetCallerSessionId(), 0, reply, &seqNumber, result); if (seqNumber == 0) { @@ -349,7 +350,7 @@ static int32_t SendReply(IpcIo *reply, uint32_t flags, int32_t result) return ERR_NONE; } -static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t listenFd) +static void ProcessTransaction(const dbinder_transaction_data *tr, uint32_t sessionId) { if (tr == NULL || tr->cookie == 0) { return; @@ -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"); } if (!(option & TF_OP_ASYNC)) { - threadContext->clientFd = listenFd; + threadContext->sessionId = sessionId; threadContext->seqNumber = senderSeqNumber; SendReply(&reply, 0, result); - threadContext->clientFd = 0; + threadContext->sessionId = 0; threadContext->seqNumber = 0; } @@ -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 listenFd) +static void ProcessReply(const dbinder_transaction_data *tr, uint32_t sessionId) { ThreadMessageInfo *messageInfo = QueryThreadBySeqNumber(tr->seqNumber); if (messageInfo == NULL) { @@ -412,14 +413,14 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd) if (messageInfo->buffer == NULL) { RPC_LOG_ERROR("some thread is waiting for reply message, but no memory"); /* wake up sender thread */ - WakeUpThreadBySeqNumber(tr->seqNumber, listenFd); + WakeUpThreadBySeqNumber(tr->seqNumber, sessionId); return; } if (memcpy_s(messageInfo->buffer, bufferSize, tr->buffer, bufferSize) != EOK) { RPC_LOG_ERROR("messageInfo buffer memset failed"); free(messageInfo->buffer); - WakeUpThreadBySeqNumber(tr->seqNumber, listenFd); + WakeUpThreadBySeqNumber(tr->seqNumber, sessionId); return; } @@ -427,10 +428,10 @@ static void ProcessReply(const dbinder_transaction_data *tr, uint32_t listenFd) messageInfo->bufferSize = tr->buffer_size; messageInfo->offsetsSize = tr->offsets_size; messageInfo->offsets = tr->offsets; - messageInfo->socketId = listenFd; + messageInfo->sessionId = sessionId; /* wake up sender thread */ - WakeUpThreadBySeqNumber(tr->seqNumber, listenFd); + WakeUpThreadBySeqNumber(tr->seqNumber, sessionId); } static void OnTransaction(ThreadProcessInfo *processInfo) @@ -442,9 +443,9 @@ static void OnTransaction(ThreadProcessInfo *processInfo) tr->buffer = (char *)(processInfo->buffer + sizeof(dbinder_transaction_data)); if (tr->cmd == BC_TRANSACTION) { - ProcessTransaction(tr, processInfo->listenFd); + ProcessTransaction(tr, processInfo->sessionId); } else if (tr->cmd == BC_REPLY) { - ProcessReply(tr, processInfo->listenFd); + ProcessReply(tr, processInfo->sessionId); } } @@ -469,7 +470,7 @@ static ThreadProcessInfo *MakeThreadProcessInfo(uint32_t handle, const char *inB free(processInfo); return NULL; } - processInfo->listenFd = handle; + processInfo->sessionId = handle; processInfo->packageSize = size; return processInfo; diff --git a/ipc/native/c/rpc/src/rpc_process_skeleton.c b/ipc/native/c/rpc/src/rpc_process_skeleton.c index 2024f1d3afbe5a0bd85fde7d8ee0bee4e7f80af3..f7faf908801bffedebfb76a5f6608d80caa1378a 100644 --- a/ipc/native/c/rpc/src/rpc_process_skeleton.c +++ b/ipc/native/c/rpc/src/rpc_process_skeleton.c @@ -438,9 +438,9 @@ void WakeUpThreadBySeqNumber(uint64_t seqNumber, uint32_t handle) return; } - if (handle != messageInfo->socketId) { + if (handle != messageInfo->sessionId) { RPC_LOG_ERROR("error! handle is not equal messageInfo, handle = %d, messageFd = %u", handle, - messageInfo->socketId); + messageInfo->sessionId); return; } if (pthread_equal(messageInfo->threadId, pthread_self()) == 0) { diff --git a/ipc/native/c/rpc/trans_adapter/include/rpc_trans.h b/ipc/native/c/rpc/trans_adapter/include/rpc_trans.h index 29e60bf53b9ac871c4ebe89b9ccf26bff94bd71d..fe1ac837d5182bbcc9908675946c973e9cdb6416 100644 --- a/ipc/native/c/rpc/trans_adapter/include/rpc_trans.h +++ b/ipc/native/c/rpc/trans_adapter/include/rpc_trans.h @@ -34,7 +34,7 @@ typedef struct { int32_t (*Connect)(const char *SaSessionName, const char *peerDeviceId, void *args); int32_t (*Disconnect)(int32_t sessionId); int32_t (*Send)(int32_t sessionId, const void *data, uint32_t len); - char (*GetLocalDeviceID)(void); + char *(*GetLocalDeviceID)(void); } TransInterface; TransInterface *GetRpcTrans(void); diff --git a/ipc/test/rpc/samgr/rpc_samgr.c b/ipc/test/rpc/samgr/rpc_samgr.c index 0f69adb1267e574ac52b816bd9f4e893916e2ffd..783a281f8abe2f281987ff85e3dcb4d765d3dc9c 100644 --- a/ipc/test/rpc/samgr/rpc_samgr.c +++ b/ipc/test/rpc/samgr/rpc_samgr.c @@ -32,6 +32,7 @@ typedef struct { static UTILS_DL_LIST *g_saList = NULL; enum { + GET_SYSTEM_ABILITY_TRANSACTION = 1, ADD_SYSTEM_ABILITY_TRANSACTION = 2, GET_REMOTE_SYSTEM_ABILITY_TRANSACTION = 3, ADD_REMOTE_SYSTEM_ABILITY_TRANSACTION = 4,