Skip to content

Commit 6f6267f

Browse files
committed
When collecting a script or unregistering a service, cancel timeouts
Both service and sysv stanzas support a cleanup:script (since v4.10), with an optional timeout. These timers must be stopped when collecting a PID for an svc_t, or when unregistering an svc_t, otherwise the timer callback will be continuously called, reporting "spurious problem", and cause 100% CPU usage. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent dec89d4 commit 6f6267f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/service.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,7 @@ void service_unregister(svc_t *svc)
20982098
return;
20992099

21002100
service_stop(svc);
2101+
service_timeout_cancel(svc);
21012102

21022103
for (c = strtok(svc->cond, ","); c; c = strtok(NULL, ","))
21032104
devmon_del_cond(c);
@@ -2137,6 +2138,10 @@ void service_monitor(pid_t lost, int status)
21372138
: (svc->state == SVC_CLEANUP_STATE
21382139
? svc->cleanup_script
21392140
: svc->pre_script)), lost, ok, sig, rc);
2141+
2142+
/* Prevent: spurious problem from timeout callback */
2143+
service_timeout_cancel(svc);
2144+
21402145
/* Kill all children in the same proess group, e.g. logit */
21412146
dbg("Killing lingering children in same process group ...");
21422147
kill(-svc->pid, SIGKILL);

0 commit comments

Comments
 (0)