!1506 modify cold start timeout

Merge pull request !1506 from 杨浩/0929timeout
This commit is contained in:
openharmony_ci 2024-10-05 15:12:48 +00:00 committed by Gitee
commit 86adf4321a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 16 additions and 7 deletions

View File

@ -569,9 +569,19 @@ static void WatchChildProcessFd(AppSpawningCtx *property)
}
}
static int IsChildColdRun(AppSpawningCtx *property)
{
return CheckAppMsgFlagsSet(property, APP_FLAGS_UBSAN_ENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_ASANENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_TSAN_ENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_HWASAN_ENABLED)
|| (property->client.flags & APP_COLD_START);
}
static int AddChildWatcher(AppSpawningCtx *property)
{
uint32_t timeout = GetSpawnTimeout(WAIT_CHILD_RESPONSE_TIMEOUT);
uint32_t defTimeout = IsChildColdRun(property) ? COLD_CHILD_RESPONSE_TIMEOUT : WAIT_CHILD_RESPONSE_TIMEOUT;
uint32_t timeout = GetSpawnTimeout(defTimeout);
LE_WatchInfo watchInfo = {};
watchInfo.fd = property->forkCtx.fd[0];
watchInfo.flags = WATCHER_ONCE;
@ -766,12 +776,9 @@ static bool IsSupportPrefork(AppSpawnContent *content, AppSpawnClient *client)
}
}
AppSpawningCtx *property = (AppSpawningCtx *)client;
bool isAsan = CheckAppMsgFlagsSet(property, APP_FLAGS_UBSAN_ENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_ASANENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_TSAN_ENABLED)
|| CheckAppMsgFlagsSet(property, APP_FLAGS_HWASAN_ENABLED);
if (content->mode == MODE_FOR_APP_SPAWN && !(client->flags & APP_COLD_START) && content->isPrefork
&& !CheckAppMsgFlagsSet(property, APP_FLAGS_CHILDPROCESS) && !isAsan) {
if (content->mode == MODE_FOR_APP_SPAWN && !IsChildColdRun(property) && content->isPrefork
&& !CheckAppMsgFlagsSet(property, APP_FLAGS_CHILDPROCESS)) {
return true;
}
return false;

View File

@ -34,9 +34,11 @@ extern "C" {
#ifdef APPSPAWN_TEST
#define MAX_WAIT_MSG_COMPLETE (5 * 100) // 500ms
#define COLD_CHILD_RESPONSE_TIMEOUT 5
#define WAIT_CHILD_RESPONSE_TIMEOUT 3 //3s
#else
#define MAX_WAIT_MSG_COMPLETE (5 * 1000) // 5s
#define COLD_CHILD_RESPONSE_TIMEOUT 5
#define WAIT_CHILD_RESPONSE_TIMEOUT 3 //3s
#endif