From 816aa9a17cd46c42dfe8eb8c485198c0a10a3b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Wed, 11 Jan 2017 16:22:48 +0100 Subject: [PATCH] pidfile: Run the reconf-callback again until no application are in flux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a service depend on the service last in the list the application will be kept in flux state forever. Signed-off-by: Mattias Walström --- plugins/pidfile.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index da86c658..7de69e83 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -30,6 +30,7 @@ #include "../cond.h" #include "../helpers.h" #include "../plugin.h" +#include "../service.h" struct context { int fd; @@ -88,16 +89,28 @@ static void pidfile_callback(void *UNUSED(arg), int fd, int UNUSED(events)) static void pidfile_reconf(void *_null) { static char name[MAX_ARG_LEN]; - svc_t *svc; (void)(_null); + int restart = 0; - for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { - if (svc->state == SVC_RUNNING_STATE && !svc_is_changed(svc) && !svc_is_starting(svc)) { + do { + restart = 0; + + for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { snprintf(name, MAX_ARG_LEN, "svc%s", svc->cmd); - cond_set_path(cond_path(name), COND_ON); + if (svc->state == SVC_RUNNING_STATE && + !svc_is_changed(svc) && + !svc_is_starting(svc) && + cond_get(name) != COND_ON) { + cond_set_path(cond_path(name), COND_ON); + restart = 1; + } } - } + + if (restart) + service_step_all(SVC_TYPE_SERVICE | SVC_TYPE_INETD); + + } while (restart); } static void pidfile_init(void *arg)