From 44d5ec37a76e8a53f2111d9e5e15439fffb93d1a Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Fri, 31 Jan 2020 08:33:36 -0800 Subject: [PATCH] init: handle process actions when waiting for exec services We currently do not handle process actions (restarting services or exiting timedout services) when we are waiting for an exec service, but this seems to be the wrong behavior. Particularly, an exec service may depend on a previously started service and if that service crashes, we will deadlock unless init restarts it. Bug: 146920034 Test: build, boot Change-Id: Id2fc936b8a7b989862ba4c32c398a544941e0e76 --- init/init.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/init/init.cpp b/init/init.cpp index a25bf6cdf..10701da69 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -780,18 +780,18 @@ int SecondStageMain(int argc, char** argv) { if (!(waiting_for_prop || Service::is_exec_service_running())) { am.ExecuteOneCommand(); } - if (!(waiting_for_prop || Service::is_exec_service_running())) { - if (!IsShuttingDown()) { - auto next_process_action_time = HandleProcessActions(); + if (!IsShuttingDown()) { + auto next_process_action_time = HandleProcessActions(); - // If there's a process that needs restarting, wake up in time for that. - if (next_process_action_time) { - epoll_timeout = std::chrono::ceil( - *next_process_action_time - boot_clock::now()); - if (*epoll_timeout < 0ms) epoll_timeout = 0ms; - } + // If there's a process that needs restarting, wake up in time for that. + if (next_process_action_time) { + epoll_timeout = std::chrono::ceil( + *next_process_action_time - boot_clock::now()); + if (*epoll_timeout < 0ms) epoll_timeout = 0ms; } + } + if (!(waiting_for_prop || Service::is_exec_service_running())) { // If there's more work to do, wake up again immediately. if (am.HasMoreCommands()) epoll_timeout = 0ms; }