diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-09-18 09:11:20 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-09-18 09:11:20 +0000 |
commit | f3441e6122c3ce8f81576bfe79897a638c8f82e2 (patch) | |
tree | 59351c47a2090ab04dda61c24059e8b4c7f8497f /src/libstore | |
parent | 26f981c2e52bb8dc91311f9a4ca53f7e37233e5c (diff) |
* Pass various options to the worker so that flags like -K or -j work
in multi-user Nix (NIX-72).
* Client/worker: exchange a protocol version number for future
compatibility.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/remote-store.cc | 23 | ||||
-rw-r--r-- | src/libstore/remote-store.hh | 2 | ||||
-rw-r--r-- | src/libstore/worker-protocol.hh | 8 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index c5d13bf49..4d866071b 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -53,18 +53,24 @@ RemoteStore::RemoteStore() from.fd = fdSocket; to.fd = fdSocket; - /* Send the magic greeting, check for the reply. */ try { writeInt(WORKER_MAGIC_1, to); - writeInt(verbosity, to); unsigned int magic = readInt(from); if (magic != WORKER_MAGIC_2) throw Error("protocol mismatch"); + + unsigned int daemonVersion = readInt(from); + if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION)) + throw Error("Nix daemon protocol version not supported"); + writeInt(PROTOCOL_VERSION, to); processStderr(); + } catch (Error & e) { throw Error(format("cannot start worker (%1%)") % e.msg()); } + + setOptions(); } @@ -154,6 +160,19 @@ RemoteStore::~RemoteStore() } +void RemoteStore::setOptions() +{ + writeInt(wopSetOptions, to); + writeInt(keepFailed, to); + writeInt(keepGoing, to); + writeInt(tryFallback, to); + writeInt(verbosity, to); + writeInt(maxBuildJobs, to); + writeInt(maxSilentTime, to); + processStderr(); +} + + bool RemoteStore::isValidPath(const Path & path) { writeInt(wopIsValidPath, to); diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index 87850c406..79a15e11e 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -77,6 +77,8 @@ private: void forkSlave(); void connectToDaemon(); + + void setOptions(); }; diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index f3b63151d..22f5973a9 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -5,8 +5,11 @@ namespace nix { -#define WORKER_MAGIC_1 0x6e697864 -#define WORKER_MAGIC_2 0x6478696e +#define WORKER_MAGIC_1 0x6e697863 +#define WORKER_MAGIC_2 0x6478696f + +#define PROTOCOL_VERSION 0x101 +#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) typedef enum { @@ -28,6 +31,7 @@ typedef enum { wopExportPath, wopImportPath, wopQueryDeriver, + wopSetOptions, } WorkerOp; |