about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-12-04T14·29+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-12-04T14·29+0000
commit909fbb9de1e3e2d020a3dd000b9009a5ff1aaeca (patch)
tree9e26c4fc9b830afa11e5ffc6746ff8f30332392d /src
parent5dfba0b4db24f4943c5b529eb3b092a64bcd6b18 (diff)
* When using build hooks, for any nix-store -r build operation, it is
  necessary that at least one build hook doesn't return "postpone",
  otherwise nix-store will barf ("waiting for a build slot, yet there
  are no running children").  So inform the build hook when this is
  the case, so that it can start a build even when that would exceed
  the maximum load on a machine.

Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index a1c99cddd040..fbec67598708 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -219,6 +219,9 @@ public:
     /* Can we start another child process? */
     bool canBuildMore();
 
+    /* Can we postpone a build right now? */
+    bool canPostpone();
+
     /* Registers a running child process.  `inBuildSlot' means that
        the process counts towards the jobs limit. */
     void childStarted(GoalPtr goal, pid_t pid,
@@ -1296,7 +1299,9 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
                 (worker.canBuildMore() ? (string) "1" : "0").c_str(),
                 thisSystem.c_str(),
                 drv.platform.c_str(),
-                drvPath.c_str(), NULL);
+                drvPath.c_str(),
+                (worker.canPostpone() ? (string) "0" : "1").c_str(),
+                NULL);
             
             throw SysError(format("executing `%1%'") % buildHook);
             
@@ -2602,6 +2607,12 @@ bool Worker::canBuildMore()
 }
 
 
+bool Worker::canPostpone()
+{
+    return children.size() != 0;
+}
+
+
 void Worker::childStarted(GoalPtr goal,
     pid_t pid, const set<int> & fds, bool inBuildSlot)
 {