From f2218836af99b705201da240b827fda712b36fef Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 30 Oct 2023 14:52:26 +0100 Subject: [PATCH] Fix #378: warn on console if run/task times out during bootstrap Signed-off-by: Joachim Wiberg --- src/service.c | 5 ++++- src/service.h | 2 +- src/sm.c | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/service.c b/src/service.c index 4a993f5c..7b758c9b 100644 --- a/src/service.c +++ b/src/service.c @@ -2609,6 +2609,7 @@ void service_runtask_clean(void) /** * service_completed - Have run/task completed in current runlevel + * @svcp: On %FALSE return, this points to the first incomplete svc * * This function checks if all run/task have run once in the current * runlevel. E.g., at bootstrap we must wait for these scripts or @@ -2621,7 +2622,7 @@ void service_runtask_clean(void) * Returns: * %TRUE(1) or %FALSE(0) */ -int service_completed(void) +int service_completed(svc_t **svcp) { svc_t *svc, *iter = NULL; @@ -2643,6 +2644,8 @@ int service_completed(void) if (!svc->once) { dbg("%s has not yet completed ...", svc_ident(svc, NULL, 0)); + if (svcp) + *svcp = svc; return 0; } dbg("%s has completed ...", svc_ident(svc, NULL, 0)); diff --git a/src/service.h b/src/service.h index bea5bc27..c8de2b9a 100644 --- a/src/service.h +++ b/src/service.h @@ -49,7 +49,7 @@ int service_step (svc_t *svc); void service_step_all (int types); void service_worker (void *unused); -int service_completed (void); +int service_completed (svc_t **svc); void service_notify_reconf (void); void service_init (uev_ctx_t *ctx); diff --git a/src/sm.c b/src/sm.c index 73850ac5..3d7c550b 100644 --- a/src/sm.c +++ b/src/sm.c @@ -53,21 +53,29 @@ sm_t sm; static void sm_check_bootstrap(void *work) { static int timeout = 120; - int level = cfglevel; + int bootstrap_done; + int level = cfglevel; + svc_t *svc = NULL; dbg("Step all services ..."); service_step_all(SVC_TYPE_ANY); - if (timeout-- > 0 && !service_completed()) { + bootstrap_done = service_completed(&svc); + if (timeout-- > 0 && !bootstrap_done) { dbg("Not all bootstrap run/tasks have completed yet ... %d", timeout); schedule_work(work); return; } - if (timeout > 0) + if (timeout > 0) { dbg("All run/task have completed, resuming bootstrap."); - else + } else { dbg("Timeout, resuming bootstrap."); + if (svc) + print(2, "Timeout waiting for %s to run, resuming bootstrap", svc_ident(svc, NULL, 0)); + else + print(2, "Timeout waiting for unknown run/task, resuming bootstrap"); + } dbg("Flushing pending .conf file events ..."); conf_flush_events();