Merge pull request !2315 from langsongping/master

Change-Id: If7a676873e925da22d06617cc31d6152b4960ae5
This commit is contained in:
openharmony_ci 2023-10-25 12:55:33 +00:00 committed by zhongning5
commit 90458fb0a7
4 changed files with 10 additions and 6 deletions

View File

@ -18,7 +18,7 @@ startup_param=40960
persist_param=40960
const_param=40960
persist_sys_param=4096
devinfo_public_param=30720
devinfo_public_param=40960
sys_param=4096
bootevent_param=4096
startup_init_param=40960

View File

@ -61,6 +61,8 @@
#define TIOCSCTTY 0x540E
#endif
#define DEF_CRASH_TIME 240000 // default crash time is 240000 ms
static int SetAllAmbientCapability(void)
{
for (int i = 0; i <= CAP_LAST_CAP; ++i) {
@ -792,7 +794,9 @@ void ServiceReap(Service *service)
}
} else if (!(service->attribute & SERVICE_ATTR_NEED_RESTART)) {
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
INIT_LOGE("Service error %s crash %d times, no more start.", service->name, service->crashCount);
INIT_LOGI("Service %s start failed! %d second later will reStart.", service->name, service->crashTime);
service->crashCnt = 0;
ServiceStartTimer(service, DEF_CRASH_TIME);
return;
}
}

View File

@ -42,7 +42,7 @@
// All service processes that init will fork+exec.
static ServiceSpace g_serviceSpace = { 0 };
static const int CRITICAL_DEFAULT_CRASH_TIME = 20;
static const int CRITICAL_DEFAULT_CRASH_TIME = 240;
// maximum number of crashes within time CRITICAL_DEFAULT_CRASH_TIME for one service
static const int CRITICAL_DEFAULT_CRASH_COUNT = 4;
static const int CRITICAL_CONFIG_ARRAY_LEN = 3;

View File

@ -164,16 +164,16 @@ HWTEST_F(ServiceUnitTest, TestServiceReap, TestSize.Level1)
service->restartArg = (CmdLines *)calloc(1, sizeof(CmdLines));
ASSERT_NE(nullptr, service->restartArg);
ServiceReap(service);
EXPECT_EQ(service->attribute, 0);
EXPECT_EQ(service->attribute, SERVICE_ATTR_TIMERSTART);
const int crashCount = 241;
service->crashCnt = crashCount;
ServiceReap(service);
EXPECT_EQ(service->attribute, 0);
EXPECT_EQ(service->attribute, SERVICE_ATTR_TIMERSTART);
service->attribute |= SERVICE_ATTR_ONCE;
ServiceReap(service);
EXPECT_EQ(service->attribute, SERVICE_ATTR_ONCE);
EXPECT_EQ(service->attribute, (SERVICE_ATTR_ONCE | SERVICE_ATTR_TIMERSTART));
service->attribute = SERVICE_ATTR_CRITICAL;
service->crashCount = 1;
ServiceReap(service);