Fix a hang during shutdown

Subtle: dhcpcd.service would call resolvconf during shutdown, which in
turn would start invalidate-nscd.service, causing the shutdown to be
cancelled.  Instead, give nscd.service a proper reload action, and do
"systemctl reload --no-block nscd.service".  The --no-block is
necessary to prevent that command from waiting until a timeout occurs
(bug in systemd?).
This commit is contained in:
Eelco Dolstra 2012-08-14 16:45:50 -04:00
parent 88bfdca8e0
commit 4475294f57
5 changed files with 10 additions and 16 deletions

@ -67,7 +67,7 @@ in
'' + optionalString config.services.nscd.enable '' '' + optionalString config.services.nscd.enable ''
# Invalidate the nscd cache whenever resolv.conf is # Invalidate the nscd cache whenever resolv.conf is
# regenerated. # regenerated.
libc_restart='${pkgs.systemd}/bin/systemctl start invalidate-nscd.service' libc_restart='${pkgs.systemd}/bin/systemctl reload --no-block nscd.service'
'' + optionalString config.services.bind.enable '' '' + optionalString config.services.bind.enable ''
# This hosts runs a full-blown DNS resolver. # This hosts runs a full-blown DNS resolver.
name_servers='127.0.0.1' name_servers='127.0.0.1'

@ -92,7 +92,8 @@ in
config = mkIf config.networking.useDHCP { config = mkIf config.networking.useDHCP {
jobs.dhcpcd = jobs.dhcpcd =
{ startOn = "started network-interfaces"; { wantedBy = [ "multi-user.target" ];
after = [ "network-interfaces.service" ];
path = [ dhcpcd pkgs.nettools pkgs.openresolv ]; path = [ dhcpcd pkgs.nettools pkgs.openresolv ];

@ -58,18 +58,11 @@ in
daemonType = "fork"; daemonType = "fork";
serviceConfig = "PIDFile=/run/nscd/nscd.pid"; serviceConfig =
}; ''
PIDFile=/run/nscd/nscd.pid
# Flush nscd's hosts database when the network comes up or the ExecReload=${pkgs.glibc}/sbin/nscd --invalidate hosts
# system configuration changes to get rid of any negative entries. '';
jobs.invalidate_nscd =
{ name = "invalidate-nscd";
description = "Invalidate NSCD cache";
startOn = "ip-up or config-changed";
after = [ "nscd.service" ];
task = true;
exec = "${pkgs.glibc}/sbin/nscd --invalidate hosts";
}; };
}; };

@ -179,4 +179,4 @@ fi
echo "starting systemd..." echo "starting systemd..."
PATH=/run/current-system/systemd/lib/systemd \ PATH=/run/current-system/systemd/lib/systemd \
MODULE_DIR=/run/current-system/kernel-modules/lib/modules \ MODULE_DIR=/run/current-system/kernel-modules/lib/modules \
exec systemd --log-target journal # --log-level debug --crash-shell exec systemd --log-target=journal # --log-level=debug --log-target=console --crash-shell