aboutsummaryrefslogtreecommitdiff
path: root/src/nix-worker
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30 20:13:59 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-11-30 20:13:59 +0000
commita711689368fe0915a2f18ea61fe6e953647d0174 (patch)
treed108cd2c072d1cf20efff5c18bd1a59b74664aa5 /src/nix-worker
parent765bdfe542d3250329dea98b69db2271419f31b6 (diff)
* First remote operation: isValidPath().
Diffstat (limited to 'src/nix-worker')
-rw-r--r--src/nix-worker/main.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/nix-worker/main.cc b/src/nix-worker/main.cc
index f71b604d0..d6966c2bf 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);
}