diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30T22·43+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2006-11-30T22·43+0000 |
commit | 0565b5f2b35dc153dc98e1e3bd37476aa13ee4f1 (patch) | |
tree | a370db3e93b6e07f044fc436092c9d082da9c8be /src/libstore | |
parent | aac547a8b3f481fda48cc1fe1082ce4c32be0e03 (diff) |
* More remote operations.
* Added new operation hasSubstitutes(), which is more efficient than querySubstitutes().size() > 0.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 2 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 8 | ||||
-rw-r--r-- | src/libstore/misc.cc | 4 | ||||
-rw-r--r-- | src/libstore/remote-store.cc | 50 | ||||
-rw-r--r-- | src/libstore/remote-store.hh | 12 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 6 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 7 | ||||
-rw-r--r-- | src/libstore/worker-protocol.hh | 7 |
8 files changed, 63 insertions, 33 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 54c48cf91fc7..ab1011981c94 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -660,7 +660,7 @@ void DerivationGoal::haveStoreExpr() i != invalidOutputs.end(); ++i) /* Don't bother creating a substitution goal if there are no substitutes. */ - if (store->querySubstitutes(*i).size() > 0) + if (store->hasSubstitutes(*i)) addWaitee(worker.makeSubstitutionGoal(*i)); if (waitees.empty()) /* to prevent hang (no wake-up event) */ diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index aa8166d7eeaf..e3f22a9c9e37 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -481,15 +481,15 @@ void registerSubstitute(const Transaction & txn, } -Substitutes querySubstitutes(const Transaction & txn, const Path & srcPath) +Substitutes querySubstitutes(const Transaction & txn, const Path & path) { - return readSubstitutes(txn, srcPath); + return readSubstitutes(txn, path); } -Substitutes LocalStore::querySubstitutes(const Path & srcPath) +Substitutes LocalStore::querySubstitutes(const Path & path) { - return nix::querySubstitutes(noTxn, srcPath); + return nix::querySubstitutes(noTxn, path); } diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 6849e2c1a64c..1319245c057c 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -64,7 +64,7 @@ void queryMissing(const PathSet & targets, for (DerivationOutputs::iterator i = drv.outputs.begin(); i != drv.outputs.end(); ++i) if (!store->isValidPath(i->second.path) && - store->querySubstitutes(i->second.path).size() == 0) + !store->hasSubstitutes(i->second.path)) mustBuild = true; if (mustBuild) { @@ -81,7 +81,7 @@ void queryMissing(const PathSet & targets, else { if (store->isValidPath(p)) continue; - if (store->querySubstitutes(p).size() > 0) + if (store->hasSubstitutes(p)) willSubstitute.insert(p); PathSet refs; store->queryReferences(p, todo); diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 99f9589bea7c..ce09ddada06a 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -39,7 +39,7 @@ RemoteStore::RemoteStore() throw SysError("dupping read side"); execlp(worker.c_str(), worker.c_str(), - "-vvv", "--slave", NULL); + "--slave", NULL); throw SysError(format("executing `%1%'") % worker); @@ -81,32 +81,44 @@ bool RemoteStore::isValidPath(const Path & path) } -Substitutes RemoteStore::querySubstitutes(const Path & srcPath) +Substitutes RemoteStore::querySubstitutes(const Path & path) { - // writeInt(wopQuerySubstitutes); - - // throw Error("not implemented 2"); - return Substitutes(); + throw Error("not implemented 2"); +} + + +bool RemoteStore::hasSubstitutes(const Path & path) +{ + writeInt(wopHasSubstitutes, to); + writeString(path, to); + unsigned int reply = readInt(from); + return reply != 0; } Hash RemoteStore::queryPathHash(const Path & path) { - throw Error("not implemented"); + throw Error("not implemented 3"); } -void RemoteStore::queryReferences(const Path & storePath, +void RemoteStore::queryReferences(const Path & path, PathSet & references) { - throw Error("not implemented"); + writeInt(wopQueryReferences, to); + writeString(path, to); + PathSet references2 = readStringSet(from); + references.insert(references2.begin(), references2.end()); } -void RemoteStore::queryReferrers(const Path & storePath, +void RemoteStore::queryReferrers(const Path & path, PathSet & referrers) { - throw Error("not implemented"); + writeInt(wopQueryReferrers, to); + writeString(path, to); + PathSet referrers2 = readStringSet(from); + referrers.insert(referrers2.begin(), referrers2.end()); } @@ -123,7 +135,7 @@ Path RemoteStore::addToStore(const Path & srcPath) Path RemoteStore::addToStoreFixed(bool recursive, string hashAlgo, const Path & srcPath) { - throw Error("not implemented 4"); + throw Error("not implemented 6"); } @@ -133,9 +145,7 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s, writeInt(wopAddTextToStore, to); writeString(suffix, to); writeString(s, to); - writeInt(references.size(), to); - for (PathSet::iterator i = references.begin(); i != references.end(); ++i) - writeString(*i, to); + writeStringSet(references, to); Path path = readString(from); return path; @@ -144,13 +154,17 @@ Path RemoteStore::addTextToStore(const string & suffix, const string & s, void RemoteStore::buildDerivations(const PathSet & drvPaths) { - throw Error("not implemented 6"); + writeInt(wopBuildDerivations, to); + writeStringSet(drvPaths, to); + readInt(from); } -void RemoteStore::ensurePath(const Path & storePath) +void RemoteStore::ensurePath(const Path & path) { - throw Error("not implemented 7"); + writeInt(wopEnsurePath, to); + writeString(path, to); + readInt(from); } diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh index da6911cf4fa2..eaa9b82ee6d9 100644 --- a/src/libstore/remote-store.hh +++ b/src/libstore/remote-store.hh @@ -27,15 +27,15 @@ public: bool isValidPath(const Path & path); - Substitutes querySubstitutes(const Path & srcPath); + Substitutes querySubstitutes(const Path & path); + bool hasSubstitutes(const Path & path); + Hash queryPathHash(const Path & path); - void queryReferences(const Path & storePath, - PathSet & references); + void queryReferences(const Path & path, PathSet & references); - void queryReferrers(const Path & storePath, - PathSet & referrers); + void queryReferrers(const Path & path, PathSet & referrers); Path addToStore(const Path & srcPath); @@ -47,7 +47,7 @@ public: void buildDerivations(const PathSet & drvPaths); - void ensurePath(const Path & storePath); + void ensurePath(const Path & path); private: Pipe toChild; diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 9e8bc36d7f0d..f1e7c35620ad 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -6,6 +6,12 @@ namespace nix { +bool StoreAPI::hasSubstitutes(const Path & path) +{ + return !querySubstitutes(path).empty(); +} + + bool isInStore(const Path & path) { return path[0] == '/' diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index abf27a346f31..31e8152e86bd 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -43,7 +43,11 @@ public: virtual bool isValidPath(const Path & path) = 0; /* Return the substitutes for the given path. */ - virtual Substitutes querySubstitutes(const Path & srcPath) = 0; + virtual Substitutes querySubstitutes(const Path & path) = 0; + + /* More efficient variant if we just want to know if a path has + substitutes. */ + virtual bool hasSubstitutes(const Path & path); /* Queries the hash of a valid path. */ virtual Hash queryPathHash(const Path & path) = 0; @@ -121,7 +125,6 @@ extern boost::shared_ptr<StoreAPI> store; boost::shared_ptr<StoreAPI> openStore(bool reserveSpace = true); - } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index dd711f3304b1..16b616c80c3e 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -10,8 +10,15 @@ typedef enum { wopQuit, wopIsValidPath, wopQuerySubstitutes, + wopHasSubstitutes, + wopQueryPathHash, + wopQueryReferences, + wopQueryReferrers, wopAddToStore, + wopAddToStoreFixed, wopAddTextToStore, + wopBuildDerivations, + wopEnsurePath, } WorkerOp; |