From a0a0a3e0a8d16980d9b65482f5035a89750d3802 Mon Sep 17 00:00:00 2001 From: wuminjie Date: Thu, 6 Mar 2025 10:05:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- samgr/source/message.c | 2 +- samgr_endpoint/source/endpoint_rpc.c | 6 +++--- .../source/samgr_small_ipc_adapter.c | 18 +++++++++--------- samgr_server/source/samgr_server_rpc.c | 3 ++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/samgr/source/message.c b/samgr/source/message.c index c35e761..a117c27 100644 --- a/samgr/source/message.c +++ b/samgr/source/message.c @@ -36,7 +36,7 @@ int32 SAMGR_SendRequest(const Identity *identity, const Request *request, Handle return EC_INVALID; } - Exchange exchange = {*identity, *request, {NULL, 0}, MSG_NON, handler, NULL}; + Exchange exchange = {*identity, *request, {NULL, 0, NULL}, MSG_NON, handler, NULL}; exchange.id.queueId = NULL; if (handler != NULL) { exchange.id.queueId = SAMGR_GetCurrentQueueID(); diff --git a/samgr_endpoint/source/endpoint_rpc.c b/samgr_endpoint/source/endpoint_rpc.c index f3048b7..65dc248 100644 --- a/samgr_endpoint/source/endpoint_rpc.c +++ b/samgr_endpoint/source/endpoint_rpc.c @@ -115,7 +115,7 @@ int32 SAMGR_AddSysCap(const Endpoint *endpoint, const char *sysCap, BOOL isReg) IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } @@ -153,7 +153,7 @@ int32 SAMGR_GetSysCap(const Endpoint *endpoint, const char *sysCap, BOOL *isReg) IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } @@ -186,7 +186,7 @@ static int SendGetAllSysCapsRequest(const Endpoint *endpoint, uint32 startIdx, I WriteUint32(&req, RES_SYSCAP); WriteUint32(&req, OP_ALL); WriteUint32(&req, startIdx); - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } diff --git a/samgr_endpoint/source/samgr_small_ipc_adapter.c b/samgr_endpoint/source/samgr_small_ipc_adapter.c index ad287df..1100133 100644 --- a/samgr_endpoint/source/samgr_small_ipc_adapter.c +++ b/samgr_endpoint/source/samgr_small_ipc_adapter.c @@ -18,8 +18,8 @@ typedef struct IRegisterEpArg IRegisterEpArg; struct IRegisterEpArg { Endpoint *endpoint; int token; - char *service; - char *feature; + const char *service; + const char *feature; }; static int Dispatch(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); static void HandleIpc(const Request *request, const Response *response); @@ -51,6 +51,7 @@ int ClientRegisterRemoteEndpoint(SvcIdentity *identity, int token, const char *s MessageOptionInit(&option); SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { + usleep(RETRY_INTERVAL); continue; } int err = SendRequest(*samgr, INVALID_INDEX, &req, &reply, option, (uintptr_t *)&replyBuf); @@ -113,14 +114,13 @@ static void *Receive(void *argv) ret = registerEpArg->endpoint->registerEP(®isterEpArg->endpoint->identity, registerEpArg->token, registerEpArg->service, registerEpArg->feature); if (ret == EC_SUCCESS) { - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { - continue; + (void)RemoveDeathRecipient(*samgr, registerEpArg->endpoint->deadId); + (void)AddDeathRecipient(*samgr, OnSamgrServerExit, registerEpArg->endpoint, + ®isterEpArg->endpoint->deadId); + break; } - (void)RemoveDeathRecipient(*samgr, registerEpArg->endpoint->deadId); - (void)AddDeathRecipient(*samgr, OnSamgrServerExit, registerEpArg->endpoint, - ®isterEpArg->endpoint->deadId); - break; } ++retry; usleep(RETRY_INTERVAL); @@ -182,7 +182,7 @@ int RegisterIdentity(const SaName *saName, SvcIdentity *saInfo, PolicyTrans **po WriteUint32(&req, saInfo->token); IpcIo reply; void *replyBuf = NULL; - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { return EC_INVALID; } diff --git a/samgr_server/source/samgr_server_rpc.c b/samgr_server/source/samgr_server_rpc.c index 6970ae6..2f4a82c 100644 --- a/samgr_server/source/samgr_server_rpc.c +++ b/samgr_server/source/samgr_server_rpc.c @@ -674,9 +674,10 @@ static cJSON *GetJsonStream() struct stat fileInfo; int32_t size = 0; - if (stat(path, &fileInfo) != 0 || (size = fileInfo.st_size) == 0) { + if (stat(path, &fileInfo) != 0 || fileInfo.st_size == 0) { return NULL; } + size = fileInfo.st_size; int32_t fp = open(path, O_RDONLY, S_IRUSR); if (fp < 0) { -- Gitee From 8b9b5ca86e580747fc11ca2bfca798679f12817b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 6 Mar 2025 06:27:23 +0000 Subject: [PATCH 2/3] update samgr/source/message.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- samgr/source/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr/source/message.c b/samgr/source/message.c index a117c27..c35e761 100644 --- a/samgr/source/message.c +++ b/samgr/source/message.c @@ -36,7 +36,7 @@ int32 SAMGR_SendRequest(const Identity *identity, const Request *request, Handle return EC_INVALID; } - Exchange exchange = {*identity, *request, {NULL, 0, NULL}, MSG_NON, handler, NULL}; + Exchange exchange = {*identity, *request, {NULL, 0}, MSG_NON, handler, NULL}; exchange.id.queueId = NULL; if (handler != NULL) { exchange.id.queueId = SAMGR_GetCurrentQueueID(); -- Gitee From ff7505ac9948f768cbff5fce6b5d4a095535a889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Thu, 6 Mar 2025 07:55:51 +0000 Subject: [PATCH 3/3] update samgr_endpoint/source/samgr_small_ipc_adapter.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- samgr_endpoint/source/samgr_small_ipc_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samgr_endpoint/source/samgr_small_ipc_adapter.c b/samgr_endpoint/source/samgr_small_ipc_adapter.c index 1100133..0203209 100644 --- a/samgr_endpoint/source/samgr_small_ipc_adapter.c +++ b/samgr_endpoint/source/samgr_small_ipc_adapter.c @@ -49,7 +49,7 @@ int ClientRegisterRemoteEndpoint(SvcIdentity *identity, int token, const char *s void *replyBuf = NULL; MessageOption option; MessageOptionInit(&option); - SvcIdentity *samgr = GetContextObject(); + const SvcIdentity *samgr = GetContextObject(); if (samgr == NULL) { usleep(RETRY_INTERVAL); continue; -- Gitee