diff options
author | jim-p <jimp@pfsense.org> | 2017-06-29 12:32:45 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-06-29 12:32:45 -0400 |
commit | 38d110824c87ff60c6289c0432d55009586ceee4 (patch) | |
tree | 1913c89ced4ca717aa0739e0698e518443d75bc6 /src/etc | |
parent | 8a0aa42c197361ebb82387e5bdc8378e5440837f (diff) | |
download | pfsense-38d110824c87ff60c6289c0432d55009586ceee4.zip pfsense-38d110824c87ff60c6289c0432d55009586ceee4.tar.gz |
Change the way unbound is stopped when the process is being restarted, to give the old process enough time to exit cleanly. Fixes #7326
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/services.inc | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index ffc4aa8..104a054 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -2235,12 +2235,24 @@ function services_unbound_configure($restart_dhcp = true) { echo "services_unbound_configure() being called $mt\n"; } - // kill any running Unbound instance - if (file_exists("{$g['varrun_path']}/unbound.pid")) { - sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM"); - } - if (isset($config['unbound']['enable'])) { + require_once('/etc/inc/unbound.inc'); + + /* Attempt to stop unbound nicely */ + do_as_unbound_user("stop"); + + /* kill Unbound if it did not stop cleanly */ + if (file_exists("{$g['varrun_path']}/unbound.pid")) { + sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM"); + } + + /* If unbound is still running, wait up to 30 seconds for it to terminate. */ + for ($i=1; $i <= 30; $i++) { + if (is_process_running('unbound')) { + sleep(1); + } + } + if (platform_booting()) { echo gettext("Starting DNS Resolver..."); } else { @@ -2252,13 +2264,17 @@ function services_unbound_configure($restart_dhcp = true) { $return = 1; } - require_once('/etc/inc/unbound.inc'); sync_unbound_service(); if (platform_booting()) { echo gettext("done.") . "\n"; } system_dhcpleases_configure(); + } else { + /* kill Unbound since it should not be enabled */ + if (file_exists("{$g['varrun_path']}/unbound.pid")) { + sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM"); + } } if (!platform_booting() && $restart_dhcp) { |