daemon/daemon.c: Fix systemd service manager state change notification
Unbound release 1.8.0 introduced a bug in the upstream commit "Fix
use-systemd readiness signalling, only when use-systemd is yes and not
in signal handler" which only performs service manager state change
notification when "use-systemd: yes" is set, which controls whether
systemd socket activation is used, according to the unbound.conf
manpage.
On Debian, since we use [Service] Type=notify in the unbound.service
unit, this causes unbound starts/restarts to hang and timeout under
1.8.0, because "use-systemd: yes" (i.e., socket activation) is not
enabled, and unbound then fails to send the state change notification.
When unbound is compiled with systemd support, it should always
sd_notify() regardless of any settings in unbound.conf, because the
process startup type is controlled by the service unit, not by the
unbound.conf file, and sd_notify()'ing when not running under a
Type=notify service unit is harmless.
This commit restores the previous behavior which was introduced by
Vincent Bernat in the fix for Debian bug #892914 [0] and applied to
upstream unbound in [1].
[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892914
[1] https://www.nlnetlabs.nl/bugs-script/show_bug.cgi?id=4108
Robert Edmonds
5 years ago
659 | 659 | |
660 | 660 | /* Start resolver service on main thread. */ |
661 | 661 | #ifdef HAVE_SYSTEMD |
662 | if(daemon->cfg->use_systemd) | |
663 | sd_notify(0, "READY=1"); | |
662 | sd_notify(0, "READY=1"); | |
664 | 663 | #endif |
665 | 664 | log_info("start of service (%s).", PACKAGE_STRING); |
666 | 665 | worker_work(daemon->workers[0]); |
667 | 666 | #ifdef HAVE_SYSTEMD |
668 | if(daemon->cfg->use_systemd) { | |
669 | if (daemon->workers[0]->need_to_exit) | |
670 | sd_notify(0, "STOPPING=1"); | |
671 | else | |
672 | sd_notify(0, "RELOADING=1"); | |
673 | } | |
667 | if (daemon->workers[0]->need_to_exit) | |
668 | sd_notify(0, "STOPPING=1"); | |
669 | else | |
670 | sd_notify(0, "RELOADING=1"); | |
674 | 671 | #endif |
675 | 672 | log_info("service stopped (%s).", PACKAGE_STRING); |
676 | 673 |