mirror of
https://github.com/troglobit/finit.git
synced 2026-11-23 20:11:44 +00:00
service: keep a stop of a forking service waiting for its PID file
Stopping a forking service after its start script had exited, but
before the daemon had written its PID file, did not hold. When the
PID file showed up, the service was reported running again and the
daemon was left alone:
initctl stop ext
service_forked() cleared any block on the service, the user's stop
included.
Keep a user stop, and let the state machine stop the late daemon of
a service no longer enabled. The service is briefly RUNNING on its
way to STOPPING, so service/NAME/running blinks on and off.
Follow-up to #452
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
5 files changed
+47
-9
No files matched your search
+14
-4
@@ -3360,16 +3360,26 @@ static void svc_set_state(svc_t *svc, svc_state_t new_state)
|
||||
/*
|
||||
* Called by pidfile plugin for forking services that have successfully started.
|
||||
* We get here when the service_monitor() collects the PID, sets svc->pid to 0,
|
||||
* and the state machine prepares for the worst bu setting state to HALTED.
|
||||
* and the state machine prepares for the worst by setting state to HALTED.
|
||||
*
|
||||
* Returns 1 if the service is now running, 0 if it was stopped or disabled
|
||||
* while waiting for its PID file, then the late daemon is stopped.
|
||||
*/
|
||||
void service_forked(svc_t *svc)
|
||||
int service_forked(svc_t *svc)
|
||||
{
|
||||
/* Stop forking_retry() timer */
|
||||
service_timeout_cancel(svc);
|
||||
|
||||
/* Not crashing, restore RUNNING state */
|
||||
svc_unblock(svc);
|
||||
/* Not crashing, restore RUNNING state, but keep a user stop */
|
||||
if (!svc_is_stopped(svc))
|
||||
svc_unblock(svc);
|
||||
svc_set_state(svc, SVC_RUNNING_STATE);
|
||||
|
||||
/* Follow-up to issue #452, RUNNING and not enabled -> service_stop() */
|
||||
if (!svc_enabled(svc))
|
||||
service_step(svc);
|
||||
|
||||
return svc_is_running(svc);
|
||||
}
|
||||
|
||||
/* Set or clear service/foo/ready condition for services and call optional ready:script */
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ int service_timeout_after (svc_t *svc, int timeout, void (*cb)(svc_t *svc
|
||||
int service_timeout_cancel (svc_t *svc);
|
||||
void compose_cmdline (svc_t *svc, char *buf, size_t len);
|
||||
|
||||
void service_forked (svc_t *svc);
|
||||
int service_forked (svc_t *svc);
|
||||
void service_ready (svc_t *svc, int ready);
|
||||
|
||||
int service_stop (svc_t *svc);
|
||||
|
||||
Reference in new issue
Block a user