mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 16:34:45 +07:00
Fix #280: allow calling initctl restart foo from within foo
Move the stop+start from initctl to the state machine by allowing stopped tasks to restart once it has been collected. This should prevent finit from blocking, allowing it to handle other requests while waiting for the service's PID to be collected. Effectively, this will allow a service to call initctl to restart itself, as reported in issue #280. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+3
-16
@@ -271,23 +271,10 @@ static int do_reload (char *arg)
|
||||
|
||||
static int do_restart(char *arg)
|
||||
{
|
||||
size_t retries = 3;
|
||||
svc_t *svc;
|
||||
if (do_startstop(INIT_CMD_RESTART_SVC, arg))
|
||||
ERRX(7, "failed restarting %s", arg);
|
||||
|
||||
if (do_startstop(INIT_CMD_STOP_SVC, arg))
|
||||
return 1;
|
||||
|
||||
while (retries-- > 0 && (svc = client_svc_find(arg))) {
|
||||
if (!svc_is_running(svc))
|
||||
break;
|
||||
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if (retries == 0)
|
||||
ERRX(7, "failed stopping %s (restart)", arg);
|
||||
|
||||
return do_startstop(INIT_CMD_RESTART_SVC, arg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user