Merge branch 'master' of ssh://git.troglobit.com:222/srv/git/finit

This commit is contained in:
Joachim Nilsson
2018-09-28 06:57:26 +02:00
4 changed files with 20 additions and 45 deletions
-5
View File
@@ -110,11 +110,6 @@ Hooks
**NOTE:** This hook callback gets the lost PID as argument.
* `HOOK_SVC_START`: Like `HOOK_SVC_LOST`, but called when a process is
started. Same caveats apply.
**NOTE:** This hook callback gets the new PID as argument.
* `HOOK_RUNLEVEL_CHANGE`: Called when the user has issued a runlevel
change. The hook is called when services not matching the new
runlevel have been been stopped. When the hook has completed, Finit
-15
View File
@@ -192,16 +192,8 @@ int plugin_exists(hook_point_t no)
/* Some hooks are called with a fixed argument, like HOOK_SVC_LOST */
void plugin_run_hook(hook_point_t no, void *arg)
{
static int last = -1;
plugin_t *p, *tmp;
/*
* End recursion: any plugin hook => start service => SVC start
* hook => start service ... err ... wait a second
*/
if (HOOK_SVC_START == last)
return;
PLUGIN_ITERATOR(p, tmp) {
if (p->hook[no].cb) {
_d("Calling %s hook n:o %d (arg: %p) ...", basename(p->name), no, arg);
@@ -209,15 +201,8 @@ void plugin_run_hook(hook_point_t no, void *arg)
}
}
/* Guard against infinite recursion */
if (HOOK_SVC_START == no)
last = no;
cond_set_oneshot(hook_cond[no]);
service_step_all(SVC_TYPE_RUNTASK);
if (HOOK_SVC_START == no)
last = -1;
}
/* Regular hooks are called with the registered plugin's argument */
-2
View File
@@ -57,7 +57,6 @@
*
* - HOOK_SVC_RECONF :: action/svc/reconf
* - HOOK_SVC_LOST :: action/svc/lost
* - HOOK_SVC_START :: action/svc/start
* - HOOK_RUNLEVEL_CHANGE :: action/sys/runlevel
*
* However, the implementation did not turn out to be stable enough for
@@ -77,7 +76,6 @@
/* Runtime hooks, runlevel [S1-9] */ \
CHOOSE(HOOK_SVC_RECONF, "nop"), \
CHOOSE(HOOK_SVC_LOST, "nop"), \
CHOOSE(HOOK_SVC_START, "nop"), \
CHOOSE(HOOK_RUNLEVEL_CHANGE, "nop"), \
\
/* Shutdown hooks, runlevel [06] */ \
+20 -23
View File
@@ -346,35 +346,35 @@ static int service_start(svc_t *svc)
svc->pid = pid;
svc->start_time = jiffies();
#ifdef INETD_ENABLED
if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM)
close(svc->stdin_fd);
#endif
if (SVC_TYPE_RUN == svc->type) {
switch (svc->type) {
case SVC_TYPE_RUN:
result = WEXITSTATUS(complete(svc->cmd, pid));
if (!svc_clean_bootstrap(svc)) {
svc->start_time = svc->pid = 0;
svc->once++;
svc_set_state(svc, SVC_STOPPING_STATE);
}
}
break;
if (svc_is_daemon(svc))
case SVC_TYPE_SERVICE:
pid_file_create(svc);
break;
#ifdef INETD_ENABLED
case SVC_TYPE_INETD_CONN:
if (svc->inetd.type == SOCK_STREAM)
close(svc->stdin_fd);
break;
#endif
default:
break;
}
sigprocmask(SIG_SETMASK, &omask, NULL);
if (do_progress)
print_result(result);
/*
* Only run hook on successful start, and *after* having printed
* the result, otherwise any hook tasks may overwrite it and the
* result would be like double "[ OK ]" but only one service.
*/
if (!result)
plugin_run_hook(HOOK_SVC_START, (void *)(uintptr_t)pid);
return result;
}
@@ -1067,13 +1067,6 @@ restart:
if (sm_is_in_teardown(&sm))
break;
/*
* Make state transition *before* service_start(), because
* of HOOK_SVC_START, which may call service_step()
*/
svc_mark_clean(svc);
svc_set_state(svc, SVC_RUNNING_STATE);
err = service_start(svc);
if (err) {
(*restart_cnt)++;
@@ -1082,6 +1075,10 @@ restart:
if (!svc_is_inetd_conn(svc))
break;
}
/* Everything went fine, clean and set state */
svc_mark_clean(svc);
svc_set_state(svc, SVC_RUNNING_STATE);
}
break;