From 9f4ec9fb7be31aaf848c3d04fb7c39313221c20f Mon Sep 17 00:00:00 2001 From: wuminjie Date: Thu, 6 Mar 2025 16:08:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- samgr_endpoint/source/endpoint_rpc.c | 6 +++--- .../source/samgr_small_ipc_adapter.c | 20 +++++++++---------- samgr_server/source/samgr_server_rpc.c | 3 ++- 3 files changed, 15 insertions(+), 14 deletions(-) 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..0203209 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); @@ -49,8 +49,9 @@ 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; } 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 02016583156409220ea313bb41ab32fd098f5362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Fri, 7 Mar 2025 01:07:42 +0000 Subject: [PATCH 2/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 0203209..fe48df2 100644 --- a/samgr_endpoint/source/samgr_small_ipc_adapter.c +++ b/samgr_endpoint/source/samgr_small_ipc_adapter.c @@ -115,7 +115,7 @@ static void *Receive(void *argv) registerEpArg->token, registerEpArg->service, registerEpArg->feature); if (ret == EC_SUCCESS) { const SvcIdentity *samgr = GetContextObject(); - if (samgr == NULL) { + if (samgr != NULL) { (void)RemoveDeathRecipient(*samgr, registerEpArg->endpoint->deadId); (void)AddDeathRecipient(*samgr, OnSamgrServerExit, registerEpArg->endpoint, ®isterEpArg->endpoint->deadId); -- Gitee From 5a86c0f0cb251f831528b3588e58e564ad9b176c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Fri, 7 Mar 2025 08:02:26 +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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samgr_endpoint/source/samgr_small_ipc_adapter.c b/samgr_endpoint/source/samgr_small_ipc_adapter.c index fe48df2..577bcc7 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; - const char *service; - const char *feature; + char *service; + char *feature; }; static int Dispatch(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option); static void HandleIpc(const Request *request, const Response *response); -- Gitee