mirror of
https://github.com/troglobit/finit.git
synced 2026-10-31 13:00:32 +00:00
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:
1 parent
77cf72cb40
commit
d66455496a
3 files changed
+16
-13
No files matched your search
+3
-3
@@ -123,11 +123,11 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
|
|||||||
if (svc->notify == SVC_NOTIFY_PID)
|
if (svc->notify == SVC_NOTIFY_PID)
|
||||||
cond_set(cond);
|
cond_set(cond);
|
||||||
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
|
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
} else if (mask & IN_DELETE) {
|
} else if (mask & IN_DELETE) {
|
||||||
cond_clear(cond);
|
cond_clear(cond);
|
||||||
if (svc->notify == SVC_NOTIFY_PID)
|
if (svc->notify == SVC_NOTIFY_PID)
|
||||||
service_ready(svc);
|
service_ready(svc, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ static void pidfile_reconf(void *arg)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (svc->notify == SVC_NOTIFY_PID)
|
if (svc->notify == SVC_NOTIFY_PID)
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
|
|
||||||
mkcond(svc, cond, sizeof(cond));
|
mkcond(svc, cond, sizeof(cond));
|
||||||
if (cond_get(cond) == COND_ON)
|
if (cond_get(cond) == COND_ON)
|
||||||
|
|||||||
+12
-9
@@ -2330,8 +2330,8 @@ void service_forked(svc_t *svc)
|
|||||||
svc_set_state(svc, SVC_RUNNING_STATE);
|
svc_set_state(svc, SVC_RUNNING_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set service/foo/ready condition for services and call optional ready:script */
|
/* Set or clear service/foo/ready condition for services and call optional ready:script */
|
||||||
void service_ready(svc_t *svc)
|
void service_ready(svc_t *svc, int ready)
|
||||||
{
|
{
|
||||||
char buf[MAX_COND_LEN];
|
char buf[MAX_COND_LEN];
|
||||||
|
|
||||||
@@ -2339,10 +2339,13 @@ void service_ready(svc_t *svc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "service/%s/ready", svc_ident(svc, NULL, 0));
|
snprintf(buf, sizeof(buf), "service/%s/ready", svc_ident(svc, NULL, 0));
|
||||||
cond_set(buf);
|
if (ready) {
|
||||||
|
cond_set(buf);
|
||||||
|
|
||||||
if (svc_has_ready(svc))
|
if (svc_has_ready(svc))
|
||||||
service_ready_script(svc);
|
service_ready_script(svc);
|
||||||
|
} else
|
||||||
|
cond_clear(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2551,7 +2554,7 @@ restart:
|
|||||||
svc_mark_clean(svc);
|
svc_mark_clean(svc);
|
||||||
}
|
}
|
||||||
if (svc->notify == SVC_NOTIFY_NONE)
|
if (svc->notify == SVC_NOTIFY_NONE)
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2585,7 +2588,7 @@ restart:
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbg("Reassert %s ready condition", svc_ident(svc, NULL, 0));
|
dbg("Reassert %s ready condition", svc_ident(svc, NULL, 0));
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2721,7 +2724,7 @@ void service_notify_reconf(void)
|
|||||||
if (svc->notify != SVC_NOTIFY_NONE && (svc_is_changed(svc) || svc_is_starting(svc)))
|
if (svc->notify != SVC_NOTIFY_NONE && (svc_is_changed(svc) || svc_is_starting(svc)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2762,7 +2765,7 @@ void service_notify_cb(uev_t *w, void *arg, int events)
|
|||||||
* the service_notify_reconf() function to step the
|
* the service_notify_reconf() function to step the
|
||||||
* generation of the READY condition.
|
* generation of the READY condition.
|
||||||
*/
|
*/
|
||||||
service_ready(svc);
|
service_ready(svc, 1);
|
||||||
|
|
||||||
/* s6 applications close their socket after notification */
|
/* s6 applications close their socket after notification */
|
||||||
if (svc->notify == SVC_NOTIFY_S6) {
|
if (svc->notify == SVC_NOTIFY_S6) {
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ int service_timeout_after (svc_t *svc, int timeout, void (*cb)(svc_t *svc
|
|||||||
int service_timeout_cancel (svc_t *svc);
|
int service_timeout_cancel (svc_t *svc);
|
||||||
|
|
||||||
void service_forked (svc_t *svc);
|
void service_forked (svc_t *svc);
|
||||||
void service_ready (svc_t *svc);
|
void service_ready (svc_t *svc, int ready);
|
||||||
|
|
||||||
int service_stop (svc_t *svc);
|
int service_stop (svc_t *svc);
|
||||||
int service_step (svc_t *svc);
|
int service_step (svc_t *svc);
|
||||||
|
|||||||
Reference in new issue
Block a user