From bcfe98acffbefea734f51523b386868ae443c111 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 4 Dec 2008 16:35:47 +0000 Subject: * Prefer building on a remote machine over a local machine. This makes more sense for the build farm, otherwise every nix-store invocation will lead to at least one local build. Will come up with a better solution later... --- scripts/build-remote.pl.in | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index 33b943602315..fe2fbaf899e6 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -45,8 +45,7 @@ mkdir $currentLoad, 0777 or die unless -d $currentLoad; my $conf = $ENV{"NIX_REMOTE_SYSTEMS"}; decline if !defined $conf || ! -e $conf; -# Decline if the local system can do the build. -decline if $amWilling && ($localSystem eq $neededSystem); +my $canBuildLocally = $amWilling && ($localSystem eq $neededSystem); # Otherwise find a willing remote machine. @@ -89,7 +88,7 @@ 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) { + while ($slot < $cur->{maxJobs} || ($mustRun && !$canBuildLocally)) { my $slotLock = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot"; open SLOTLOCK, ">>$slotLock" or die; if (flock(SLOTLOCK, LOCK_EX | LOCK_NB)) { @@ -107,9 +106,11 @@ LOOP: foreach my $cur (@machines) { close MAINLOCK; -# Didn't find one? +# Didn't find one? Then decline or postpone. if (!defined $machine) { - if ($rightType) { + # Postpone if we have a machine of the right type, except if the + # local system can and wants to do the build. + if ($rightType && !$canBuildLocally) { sendReply "postpone"; exit 0; } else { -- cgit 1.4.1