From eaced2e4d87db85eadcfabaab3b4fee6f75f15a1 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Mon, 1 Sep 2025 15:12:46 +0800 Subject: [PATCH] check spawning status before stopping nativespawn Signed-off-by: nianyuu --- interfaces/innerkits/client/appspawn_client.c | 8 ++++---- standard/appspawn_appmgr.c | 1 + standard/appspawn_main.c | 3 +++ standard/appspawn_service.c | 7 ++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/interfaces/innerkits/client/appspawn_client.c b/interfaces/innerkits/client/appspawn_client.c index bef4315b..5699112c 100644 --- a/interfaces/innerkits/client/appspawn_client.c +++ b/interfaces/innerkits/client/appspawn_client.c @@ -432,16 +432,16 @@ int AppSpawnClientSendMsg(AppSpawnClientHandle handle, AppSpawnReqMsgHandle reqH APPSPAWN_CHECK(reqNode != NULL && reqNode->msg != NULL, AppSpawnReqMsgFree(reqHandle); return APPSPAWN_ARG_INVALID, "Invalid msgReq"); - APPSPAWN_LOGI("AppSpawnClientSendMsg reqId: %{public}u msgLen: %{public}u %{public}s", - reqNode->reqId, reqNode->msg->msgLen, reqNode->msg->processName); + APPSPAWN_LOGI("AppSpawnClientSendMsg reqId: %{public}u msgLen: %{public}u fd: %{public}d %{public}s", + reqNode->reqId, reqNode->msg->msgLen, reqMgr->socketId, reqNode->msg->processName); pthread_mutex_lock(&reqMgr->mutex); int ret = ClientSendMsg(reqMgr, reqNode, result); if (ret != 0) { result->result = ret; } pthread_mutex_unlock(&reqMgr->mutex); - APPSPAWN_LOGI("AppSpawnClientSendMsg reqId: %{public}u end result: 0x%{public}x pid: %{public}d", - reqNode->reqId, result->result, result->pid); + APPSPAWN_LOGI("AppSpawnClientSendMsg reqId: %{public}u fd: %{public}d end result: 0x%{public}x pid: %{public}d", + reqNode->reqId, reqMgr->socketId, result->result, result->pid); AppSpawnReqMsgFree(reqHandle); return ret; } diff --git a/standard/appspawn_appmgr.c b/standard/appspawn_appmgr.c index 4aa77019..b864d494 100644 --- a/standard/appspawn_appmgr.c +++ b/standard/appspawn_appmgr.c @@ -320,6 +320,7 @@ void DeleteAppSpawningCtx(AppSpawningCtx *property) DeleteAppSpawnMsg(&property->message); OH_ListRemove(&property->node); + OH_ListInit(&property->node); if (property->forkCtx.timer) { LE_StopTimer(LE_GetDefaultLoop(), property->forkCtx.timer); property->forkCtx.timer = NULL; diff --git a/standard/appspawn_main.c b/standard/appspawn_main.c index bed93f4d..f3f753bb 100644 --- a/standard/appspawn_main.c +++ b/standard/appspawn_main.c @@ -21,6 +21,7 @@ #include "appspawn_modulemgr.h" #include "appspawn_manager.h" #include "appspawn_service.h" +#include "appspawn_trace.h" #include "parameter.h" #include "securec.h" @@ -154,7 +155,9 @@ int main(int argc, char *const argv[]) arg->serviceName); } } + StartAppspawnTrace("StartSpawnService"); AppSpawnContent *content = StartSpawnService(arg, argvSize, argc, argv); + FinishAppspawnTrace(); if (content != NULL) { content->runAppSpawn(content, argc, argv); } diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index 51eeec66..b281c669 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -200,7 +200,8 @@ APPSPAWN_STATIC void ProcessSignal(const struct signalfd_siginfo *siginfo) HandleDiedPid(pid, siginfo->ssi_uid, status); } #if (defined(CJAPP_SPAWN) || defined(NATIVE_SPAWN)) - if (OH_ListGetCnt(&GetAppSpawnMgr()->appQueue) == 0) { + if (OH_ListGetCnt(&GetAppSpawnMgr()->appQueue) == 0 && + OH_ListGetCnt(&GetAppSpawnMgr()->appSpawnQueue) == 0) { LE_StopLoop(LE_GetDefaultLoop()); } #endif @@ -1394,14 +1395,18 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar } // load module appspawn/common + StartAppspawnTrace("AppSpawnLoadCommonModules"); AppSpawnLoadAutoRunModules(MODULE_COMMON); + FinishAppspawnTrace(); AppSpawnModuleMgrInstall(ASAN_MODULE_PATH); APPSPAWN_CHECK(LE_GetDefaultLoop() != NULL, return NULL, "Invalid default loop"); AppSpawnContent *content = AppSpawnCreateContent(arg->socketName, argv[0], argvSize, arg->mode); APPSPAWN_CHECK(content != NULL, return NULL, "Failed to create content for %{public}s", arg->socketName); + StartAppspawnTrace("AppSpawnLoadAutoRunModules"); AppSpawnLoadAutoRunModules(arg->moduleType); // load corresponding plugin according to startup mode + FinishAppspawnTrace(); int ret = ServerStageHookExecute(STAGE_SERVER_PRELOAD, content); // Preload, prase the sandbox APPSPAWN_CHECK(ret == 0, AppSpawnDestroyContent(content); return NULL, "Failed to prepare load %{public}s result: %{public}d", arg->serviceName, ret); -- Gitee