about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-03-29T18·00+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-03-29T18·00+0000
commit737423a89c4b5f666fb4daf61775764b66911cf1 (patch)
tree883fee6aebdc231a721f372753f21d44ba020226
parent47706e3924cf592a4e0085eb2e45f0e84b67f933 (diff)
* Use polling to wait for a remote build slot when using a build hook
  (that is, call the build hook with a certain interval until it
  accepts the build).
* build-remote.pl was totally broken: for all system types other than
  the local system type, it would send all builds to the *first*
  machine of the appropriate type.

-rwxr-xr-xscripts/build-remote.pl.in7
-rw-r--r--src/libstore/build.cc32
2 files changed, 3 insertions, 36 deletions
diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in
index ef8d3bbea02c..03bceb884f2a 100755
--- a/scripts/build-remote.pl.in
+++ b/scripts/build-remote.pl.in
@@ -23,8 +23,7 @@ use English '-no_match_vars';
 
 my $loadIncreased = 0;
 
-my ($amWilling, $localSystem, $neededSystem, $drvPath, $mustRun, $maxSilentTime) = @ARGV;
-$mustRun = 0 unless defined $mustRun;
+my ($amWilling, $localSystem, $neededSystem, $drvPath, $maxSilentTime) = @ARGV;
 $maxSilentTime = 0 unless defined $maxSilentTime;
 
 sub sendReply {
@@ -87,12 +86,10 @@ LOOP: foreach my $cur (@machines) {
         # We have a machine of the right type.  Try to get a lock on
         # one of the machine's lock files.
         my $slot = 0;
-        while ($slot < $cur->{maxJobs} || ($mustRun && !$canBuildLocally)) {
+        while ($slot < $cur->{maxJobs}) {
             my $slotLock = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot";
             open SLOTLOCK, ">>$slotLock" or die;
             if (flock(SLOTLOCK, LOCK_EX | LOCK_NB)) {
-                print STDERR "warning: exceeding maximum load on " . $cur->{systemType} . "\n"
-                    if $slot >= $cur->{maxJobs};
                 $machine = $cur;
                 last LOOP;
             }
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 6c24a2746dd4..d80c67358b86 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -52,9 +52,6 @@ namespace nix {
 using std::map;
     
 
-/* !!! TODO derivationFromPath shouldn't be used here */
-
-
 static string pathNullDevice = "/dev/null";
 
 
@@ -229,9 +226,6 @@ 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,
@@ -247,10 +241,6 @@ public:
        might be right away). */
     void waitForBuildSlot(GoalPtr goal);
 
-    /* Put `goal' to sleep until a child process terminates, i.e., a
-       call is made to childTerminate(..., true).  */
-    void waitForChildTermination(GoalPtr goal);
-
     /* Wait for any goal to finish.  Pretty indiscriminate way to
        wait for some resource that some other goal is holding. */
     void waitForAnyGoal(GoalPtr goal);
@@ -1041,7 +1031,7 @@ void DerivationGoal::tryToBuild()
             return;
         case rpPostpone:
             /* Not now; wait until at least one child finishes. */
-            worker.waitForChildTermination(shared_from_this());
+            worker.waitForAWhile(shared_from_this());
             outputLocks.unlock();
             return;
         case rpDecline:
@@ -1246,7 +1236,6 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
                 thisSystem.c_str(),
                 drv.platform.c_str(),
                 drvPath.c_str(),
-                (worker.canPostpone() ? (string) "0" : "1").c_str(),
                 (format("%1%") % maxSilentTime).str().c_str(),
                 NULL);
             
@@ -2243,8 +2232,6 @@ void SubstitutionGoal::tryToRun()
 
             logPipe.readSide.close();
 
-            /* !!! close other handles */
-
             commonChildInit(logPipe);
 
             /* Fill in the arguments. */
@@ -2286,7 +2273,6 @@ void SubstitutionGoal::finished()
 
     /* Since we got an EOF on the logger pipe, the substitute is
        presumed to have terminated.  */
-    /* !!! this could block! */
     pid_t savedPid = pid;
     int status = pid.wait(true);
 
@@ -2469,12 +2455,6 @@ bool Worker::canBuildMore()
 }
 
 
-bool Worker::canPostpone()
-{
-    return children.size() != 0;
-}
-
-
 void Worker::childStarted(GoalPtr goal,
     pid_t pid, const set<int> & fds, bool inBuildSlot)
 {
@@ -2527,16 +2507,6 @@ void Worker::waitForBuildSlot(GoalPtr goal)
 }
 
 
-void Worker::waitForChildTermination(GoalPtr goal)
-{
-    debug("wait for child termination");
-    if (children.size() == 0)
-        throw Error("waiting for a build slot, yet there are no running children - "
-            "maybe the build hook gave an inappropriate `postpone' reply?");
-    wantingToBuild.insert(goal);
-}
-
-
 void Worker::waitForAnyGoal(GoalPtr goal)
 {
     debug("wait for any goal");