From 97421eb5ecde86b75441094fda017b12b5eca2a6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Jul 2012 19:55:41 -0400 Subject: Refactor settings processing Put all Nix configuration flags in a Settings object. --- src/nix-worker/nix-worker.cc | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/nix-worker/nix-worker.cc') diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc index 09800c16087a..84ad689048a0 100644 --- a/src/nix-worker/nix-worker.cc +++ b/src/nix-worker/nix-worker.cc @@ -527,27 +527,23 @@ static void performOp(unsigned int clientVersion, } case wopSetOptions: { - keepFailed = readInt(from) != 0; - keepGoing = readInt(from) != 0; - tryFallback = readInt(from) != 0; + settings.keepFailed = readInt(from) != 0; + settings.keepGoing = readInt(from) != 0; + settings.tryFallback = readInt(from) != 0; verbosity = (Verbosity) readInt(from); - maxBuildJobs = readInt(from); - maxSilentTime = readInt(from); + settings.maxBuildJobs = readInt(from); + settings.maxSilentTime = readInt(from); if (GET_PROTOCOL_MINOR(clientVersion) >= 2) - useBuildHook = readInt(from) != 0; + settings.useBuildHook = readInt(from) != 0; if (GET_PROTOCOL_MINOR(clientVersion) >= 4) { - buildVerbosity = (Verbosity) readInt(from); + settings.buildVerbosity = (Verbosity) readInt(from); logType = (LogType) readInt(from); - printBuildTrace = readInt(from) != 0; + settings.printBuildTrace = readInt(from) != 0; } if (GET_PROTOCOL_MINOR(clientVersion) >= 6) - buildCores = readInt(from); - if (GET_PROTOCOL_MINOR(clientVersion) >= 10) { - int x = readInt(from); - Strings ss; - ss.push_back(x == 0 ? "false" : "true"); - overrideSetting("build-use-substitutes", ss); - } + settings.buildCores = readInt(from); + if (GET_PROTOCOL_MINOR(clientVersion) >= 10) + settings.useSubstitutes = readInt(from) != 0; startWork(); stopWork(); break; @@ -768,7 +764,7 @@ static void daemonLoop() if (fdSocket == -1) throw SysError("cannot create Unix domain socket"); - string socketPath = nixStateDir + DEFAULT_SOCKET_PATH; + string socketPath = settings.nixStateDir + DEFAULT_SOCKET_PATH; createDirs(dirOf(socketPath)); @@ -867,10 +863,6 @@ static void daemonLoop() strncpy(argvSaved[1], processName.c_str(), strlen(argvSaved[1])); } - /* Since the daemon can be long-running, the - settings may have changed. So force a reload. */ - reloadSettings(); - /* Handle the connection. */ from.fd = remote; to.fd = remote; -- cgit 1.4.1