未验证 提交 a4012d6b 编写于 作者: O openharmony_ci 提交者: Gitee

!1666 panic触发重启也走reboot前的sync流程

Merge pull request !1666 from linrj/master
......@@ -487,19 +487,6 @@ static void CheckOndemandService(Service *service)
}
}
static void DoCriticalServiceAbnormal(void) {
FILE *panic = fopen("/proc/sysrq-trigger", "wb");
if (panic == NULL) {
ExecReboot("reboot");
return;
}
#ifndef STARTUP_INIT_TEST
fwrite((void *)"c", 1, 1, panic);
#endif
fclose(panic);
}
void ServiceReap(Service *service)
{
INIT_CHECK(service != NULL, return);
......@@ -542,7 +529,7 @@ void ServiceReap(Service *service)
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
INIT_LOGE("Critical service \" %s \" crashed %d times, rebooting system",
service->name, service->crashCount);
DoCriticalServiceAbnormal();
ExecReboot("panic");
}
} else if (!(service->attribute & SERVICE_ATTR_NEED_RESTART)) {
if (!CalculateCrashTime(service, service->crashTime, service->crashCount)) {
......
......@@ -25,7 +25,11 @@ void ExecReboot(const char *value)
#ifndef STARTUP_INIT_TEST
// install module
InitModuleMgrInstall("rebootmodule");
PluginExecCmdByName("reboot", value);
if (strstr(value, "reboot") != NULL) {
PluginExecCmdByName("reboot", value);
} else {
PluginExecCmdByName(value, value);
}
#endif
return;
}
......
......@@ -48,6 +48,26 @@ static int DoReboot(int id, const char *name, int argc, const char **argv)
return DoRoot_("reboot", RB_AUTOBOOT);
}
static int DoRebootPanic(int id, const char *name, int argc, const char **argv)
{
UNUSED(id);
UNUSED(name);
UNUSED(argc);
UNUSED(argv);
// clear misc
(void)UpdateMiscMessage(NULL, "reboot", NULL, NULL);
DoJobNow("reboot");
#ifndef STARTUP_INIT_TEST
FILE *panic = fopen("/proc/sysrq-trigger", "wb");
if (panic == NULL) {
return reboot(RB_AUTOBOOT);
}
fwrite((void *)"c", 1, 1, panic);
fclose(panic);
#endif
return 0;
}
static int DoRebootShutdown(int id, const char *name, int argc, const char **argv)
{
UNUSED(id);
......@@ -130,6 +150,8 @@ static void RebootAdpInit(void)
AddRebootCmdExecutor("updater", DoRebootUpdater);
AddRebootCmdExecutor("charge", DoRebootCharge);
AddRebootCmdExecutor("suspend", DoRebootSuspend);
AddRebootCmdExecutor("panic", DoRebootPanic);
(void)AddCmdExecutor("panic", DoRebootPanic);
}
MODULE_CONSTRUCTOR(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册