From 02e69932ae90132d80780584b1d86a3bf314e2e4 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 7 Dec 2016 21:51:54 +0100 Subject: [PATCH] Fix inetd regression introduced in 10b72f1 This patch allows all services to go from READY -> RUNNING, this to prevent started inetd connections from being treated as "stubborn" and inadvertently killing them off after a few seconds. The same actually applies to run/task applications. Signed-off-by: Joachim Nilsson --- service.c | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/service.c b/service.c index fc5e7a9f..50637366 100644 --- a/service.c +++ b/service.c @@ -890,23 +890,7 @@ restart: } svc_mark_clean(svc); - - switch (svc->type) { - case SVC_TYPE_INETD: - case SVC_TYPE_SERVICE: - svc_set_state(svc, SVC_RUNNING_STATE); - break; - - case SVC_TYPE_INETD_CONN: - case SVC_TYPE_TASK: - case SVC_TYPE_RUN: - svc_set_state(svc, SVC_STOPPING_STATE); - break; - - default: - _e("unknown service type %d", svc->type); - break; - } + svc_set_state(svc, SVC_RUNNING_STATE); } break; @@ -917,17 +901,25 @@ restart: break; } - if (!svc->pid && !svc_is_inetd(svc)) { - svc_restarting(svc); - svc_set_state(svc, SVC_HALTED_STATE); + if (!svc->pid) { + if (svc_is_daemon(svc)) { + svc_restarting(svc); + svc_set_state(svc, SVC_HALTED_STATE); - /* - * Restart directly after the first crash, - * then retry after 2 sec - */ - _d("delayed restart of %s", svc->desc); - service_timeout_after(svc, 1, service_retry); - break; + /* + * Restart directly after the first crash, + * then retry after 2 sec + */ + _d("delayed restart of %s", svc->desc); + service_timeout_after(svc, 1, service_retry); + break; + } + + /* Collected inetd connection, drive it to stopping */ + if (svc_is_inetd_conn(svc)) { + svc_set_state(svc, SVC_STOPPING_STATE); + break; + } } cond = cond_get_agg(svc->cond);