mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
pidfile: Run the reconf-callback again until no application are in flux
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 <mattias.walstrom@westermo.se>
This commit is contained in:
+18
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user