Control: found -1 3:5.39-2
On Mon, 06 Apr 2015 19:16:24 +0200 Tollef Fog Heen wrote:
> Nothing here ensures the daemons have actually exited before it tries to
> start the new daemon.
>
> There's a variant of the same bug in that the init script will return on
> stop before the daemon has actually stopped. Should be easy enough to
> fix with a loop in killdaemons, or by using start-stop-daemon instead
> which will wait for you.
Unfortunately, this bug is still present and probably wasn't fixed in
the intermediate versions either. In my reading the killproc function
does not wait for the signalled process to exit, so nothing changed with
the init script rework in this respect. To make stunnel always lose the
exit race, I recompiled with the following patch:
--- a/src/stunnel.c
+++ b/src/stunnel.c
@@ -309,6 +309,7 @@
sleep(1); /* to avoid log trashing */
}
}
+sleep (10); /* wait before exiting */
}
/* return 1 when a short delay is needed before another try */
Still, "systemctl stop stunnel4" is instantenous, and leaves behind the
stunnel4 process for 10 seconds. I tested with the shipped sample
config, with and without the "pid" directive. Restart also fails:
Jun 20 14:06:01 elm systemd[1]: Stopping LSB: Start or stop stunnel 4.x (TLS
tunnel for network daemons)...
Jun 20 14:06:01 elm stunnel: LOG5[main]: Terminated
Jun 20 14:06:01 elm stunnel4[1000]: Stopping TLS tunnels:
/etc/stunnel/sample.conf: stopped
Jun 20 14:06:01 elm systemd[1]: Stopped LSB: Start or stop stunnel 4.x (TLS
tunnel for network daemons).
Jun 20 14:06:01 elm systemd[1]: Starting LSB: Start or stop stunnel 4.x (TLS
tunnel for network daemons)...
Jun 20 14:06:01 elm stunnel4[1020]: Starting TLS tunnels:
/etc/stunnel/sample.conf: started
Jun 20 14:06:01 elm systemd[1]: Started LSB: Start or stop stunnel 4.x (TLS
tunnel for network daemons).
No errors, but the old stunnel4 process exits 10 seconds later, and no
new one is started. I wasn't able to capture logs of this, but the new
process couldn't bind its listening sockets while the old one was still
running. #535924 did a better job on this, this needs investigation.
So I think the init script is still broken. Actually, an init script in
itself will never be fully correct under systemd because of the default
RemainAfterExit=yes in its SysV compatibility layer. So providing a
standalone systemd service file would be the best solution. I'd
recommend adding Type=notify support upstream (should be straightforward)
to avoid the need for PID files and using templated service (and for
bonus points, optionally socket) units for properly managing multiple
config files. However, as I read, upstream wants to move away from
supporting independent daemons (which is perfectly reasonable, as a
single daemon is multiplexing anyway), so the template stuff could be
left out without significant loss. #826883 should be linked here.
I'm willing to help with the above if needed. Unfortunately, this issue
now affects stretch as well, but probably can't be solved via a stable
update, being too fundamental.
--
Regards,
Feri