Fix #392: ensure 'ready' condition is cleared on pidfile removal

A service with notify:pid is 'ready' when the pidfile has been created,
the converse also holds true -- when a pidfile is removed the service is
no longer 'ready'.

The state transition for the service has probably already been done, in
svc_set_state(), clearing all <service/foo/*> conditions when the PID
was collected.  The pidfile event may arrive later, so for completeness
we make sure the 'ready' condition is not recreated at least.

Problem introduced in 912a281 with the original supoport for service
readiness notification.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-01-06 12:25:41 +01:00
parent 77cf72cb40
commit d66455496a
3 changed files with 16 additions and 13 deletions
+3 -3
View File
@@ -123,11 +123,11 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
if (svc->notify == SVC_NOTIFY_PID)
cond_set(cond);
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
service_ready(svc);
service_ready(svc, 1);
} else if (mask & IN_DELETE) {
cond_clear(cond);
if (svc->notify == SVC_NOTIFY_PID)
service_ready(svc);
service_ready(svc, 0);
}
}
@@ -242,7 +242,7 @@ static void pidfile_reconf(void *arg)
continue;
if (svc->notify == SVC_NOTIFY_PID)
service_ready(svc);
service_ready(svc, 1);
mkcond(svc, cond, sizeof(cond));
if (cond_get(cond) == COND_ON)