Fix segfault, stop a crashing service before deleting it

Finit tries to restart crashing services.  If a service is removed
before Finit has given up restarting it, then the background timer
responsible the restart may dereference a free():d svc_t.

Hence, make sure to properly stop (and step) a service and its timer
callbacks in service_unregister() before calling svc_del().

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-01-19 16:27:25 +01:00
parent fa02b59db5
commit 268304927d
+3
View File
@@ -857,6 +857,9 @@ void service_unregister(svc_t *svc)
if (!svc)
return;
service_stop(svc);
service_step(svc);
if (svc_is_inetd(svc)) {
if (svc_is_busy(svc->inetd.svc)) {
svc_unblock(svc->inetd.svc);