diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30T20·13+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30T20·13+0000 |
commit | a711689368fe0915a2f18ea61fe6e953647d0174 (patch) | |
tree | d108cd2c072d1cf20efff5c18bd1a59b74664aa5 /src/nix-worker/main.cc | |
parent | 765bdfe542d3250329dea98b69db2271419f31b6 (diff) |
* First remote operation: isValidPath().
Diffstat (limited to 'src/nix-worker/main.cc')
-rw-r--r-- | src/nix-worker/main.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc index f71b604d0102..d6966c2bf5ee 100644 --- a/src/nix-worker/main.cc +++ b/src/nix-worker/main.cc @@ -2,6 +2,7 @@ #include "local-store.hh" #include "util.hh" #include "serialise.hh" +#include "worker-protocol.hh" using namespace nix; @@ -11,11 +12,39 @@ void processConnection(Source & from, Sink & to) store = boost::shared_ptr<StoreAPI>(new LocalStore(true)); unsigned int magic = readInt(from); - if (magic != 0x6e697864) throw Error("protocol mismatch"); + if (magic != WORKER_MAGIC_1) throw Error("protocol mismatch"); - writeInt(0x6478696e, to); + writeInt(WORKER_MAGIC_2, to); debug("greeting exchanged"); + + bool quit = false; + + do { + + WorkerOp op = (WorkerOp) readInt(from); + + switch (op) { + + case wopQuit: + /* Close the database. */ + store.reset((StoreAPI *) 0); + writeInt(1, to); + quit = true; + break; + + case wopIsValidPath: { + Path path = readString(from); + assertStorePath(path); + writeInt(store->isValidPath(path), to); + break; + } + + default: + throw Error("invalid operation"); + } + + } while (!quit); } |