From a55113411fe8e6ef39e24c79564e39f07f5a8fdf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Nov 2008 12:25:11 +0000 Subject: [PATCH] * Nix daemon: reload the configuration file after forking (NIX-100). --- src/libstore/globals.cc | 7 +++++++ src/libstore/globals.hh | 2 ++ src/nix-worker/nix-worker.cc | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 19087f657..27d75faec 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -118,5 +118,12 @@ unsigned int queryIntSetting(const string & name, unsigned int def) return n; } + +void reloadSettings() +{ + settingsRead = false; + settings.clear(); +} + } diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 2eb68625a..7e973025c 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -107,6 +107,8 @@ bool queryBoolSetting(const string & name, bool def); unsigned int queryIntSetting(const string & name, unsigned int def); +void reloadSettings(); + } diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc index dc9db0be4..1ba74f46f 100644 --- a/src/nix-worker/nix-worker.cc +++ b/src/nix-worker/nix-worker.cc @@ -627,13 +627,17 @@ static void daemonLoop() case 0: try { /* child */ - + /* Background the worker. */ if (setsid() == -1) throw SysError(format("creating a new session")); /* Restore normal handling of SIGCHLD. */ setSigChldAction(false); + + /* Since the daemon can be long-running, the + settings may have changed. So force a reload. */ + reloadSettings(); /* Handle the connection. */ from.fd = remote;