mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Clear pid condition on service collection to fix stale deps
In a setup like this, when 'netd' is marked dirty and subsequently is reloaded, e.g., using 'initctl reload', zebra is properly restarted, but staticd isn't: mgmtd <!> ← netd <pid/mgmtd> ← zebra <!pid/netd> ← staticd <!pid/zebra> Finit must invalidate the condition of zebra to trigger a restart also of staticd. This to guard against daemons like zebra that may fail to clean up their pidfiles. Fixes #475 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -1093,6 +1093,7 @@ static void service_notify_stop(svc_t *svc)
|
||||
*/
|
||||
static void service_cleanup(svc_t *svc)
|
||||
{
|
||||
char cond[MAX_COND_LEN];
|
||||
char *fn;
|
||||
|
||||
/* PID collected, cancel any pending SIGKILL */
|
||||
@@ -1103,6 +1104,18 @@ static void service_cleanup(svc_t *svc)
|
||||
logit(LOG_CRIT, "Failed removing service %s pidfile %s",
|
||||
svc_ident(svc, NULL, 0), fn);
|
||||
|
||||
/*
|
||||
* Invalidate the pid/ condition for this service to ensure
|
||||
* dependent services are properly stopped and restarted.
|
||||
* Without this, the condition is only cleared asynchronously
|
||||
* via inotify on pidfile removal, which may not trigger when
|
||||
* the daemon fails to clean up its own pidfile, or when the
|
||||
* service dies during a reload cycle and goes directly from
|
||||
* RUNNING to HALTED (skipping STOPPING where cond_clear()
|
||||
* is normally called).
|
||||
*/
|
||||
cond_clear(mkcond(svc, cond, sizeof(cond)));
|
||||
|
||||
service_notify_stop(svc);
|
||||
|
||||
/* No longer running, update books. */
|
||||
|
||||
Reference in New Issue
Block a user