Remove HOOK_SVC_START, caused more problems than it was worth

An operator wanting to monitor processes started by Finit could use the
kernel ftrace framework.  E.g. execsnoop in perf-tools.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2018-09-28 06:49:49 +02:00
1 parent 9516c28a8a
commit a5491b3ded
4 files changed
+4 -37

No files matched your search

-5
View File
@@ -110,11 +110,6 @@ Hooks
**NOTE:** This hook callback gets the lost PID as argument. **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 * `HOOK_RUNLEVEL_CHANGE`: Called when the user has issued a runlevel
change. The hook is called when services not matching the new change. The hook is called when services not matching the new
runlevel have been been stopped. When the hook has completed, Finit 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 */ /* Some hooks are called with a fixed argument, like HOOK_SVC_LOST */
void plugin_run_hook(hook_point_t no, void *arg) void plugin_run_hook(hook_point_t no, void *arg)
{ {
static int last = -1;
plugin_t *p, *tmp; 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) { PLUGIN_ITERATOR(p, tmp) {
if (p->hook[no].cb) { if (p->hook[no].cb) {
_d("Calling %s hook n:o %d (arg: %p) ...", basename(p->name), no, arg); _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]); cond_set_oneshot(hook_cond[no]);
service_step_all(SVC_TYPE_RUNTASK); service_step_all(SVC_TYPE_RUNTASK);
if (HOOK_SVC_START == no)
last = -1;
} }
/* Regular hooks are called with the registered plugin's argument */ /* 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_RECONF :: action/svc/reconf
* - HOOK_SVC_LOST :: action/svc/lost * - HOOK_SVC_LOST :: action/svc/lost
* - HOOK_SVC_START :: action/svc/start
* - HOOK_RUNLEVEL_CHANGE :: action/sys/runlevel * - HOOK_RUNLEVEL_CHANGE :: action/sys/runlevel
* *
* However, the implementation did not turn out to be stable enough for * However, the implementation did not turn out to be stable enough for
@@ -77,7 +76,6 @@
/* Runtime hooks, runlevel [S1-9] */ \ /* Runtime hooks, runlevel [S1-9] */ \
CHOOSE(HOOK_SVC_RECONF, "nop"), \ CHOOSE(HOOK_SVC_RECONF, "nop"), \
CHOOSE(HOOK_SVC_LOST, "nop"), \ CHOOSE(HOOK_SVC_LOST, "nop"), \
CHOOSE(HOOK_SVC_START, "nop"), \
CHOOSE(HOOK_RUNLEVEL_CHANGE, "nop"), \ CHOOSE(HOOK_RUNLEVEL_CHANGE, "nop"), \
\ \
/* Shutdown hooks, runlevel [06] */ \ /* Shutdown hooks, runlevel [06] */ \
+4 -15
View File
@@ -367,14 +367,6 @@ static int service_start(svc_t *svc)
if (do_progress) if (do_progress)
print_result(result); 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; return result;
} }
@@ -1044,13 +1036,6 @@ restart:
if (sm_is_in_teardown(&sm)) if (sm_is_in_teardown(&sm))
break; 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); err = service_start(svc);
if (err) { if (err) {
(*restart_cnt)++; (*restart_cnt)++;
@@ -1059,6 +1044,10 @@ restart:
if (!svc_is_inetd_conn(svc)) if (!svc_is_inetd_conn(svc))
break; break;
} }
/* Everything went fine, clean and set state */
svc_mark_clean(svc);
svc_set_state(svc, SVC_RUNNING_STATE);
} }
break; break;