From 096affb55b06c1280df9ff6b1fd5111d5745b57a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 29 Mar 2009 18:40:44 +0000 Subject: [PATCH] * Update the mtime on the lock file to make it easy to see when a slot was last used. --- scripts/build-remote.pl.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in index 03bceb884f..7c2797f5d0 100755 --- a/scripts/build-remote.pl.in +++ b/scripts/build-remote.pl.in @@ -3,6 +3,7 @@ use strict; use Fcntl ':flock'; use English '-no_match_vars'; +use IO::Handle; # General operation: # @@ -79,6 +80,7 @@ flock(MAINLOCK, LOCK_EX) or die; # Find a suitable system. my $rightType = 0; my $machine; +my $slotLock; LOOP: foreach my $cur (@machines) { if ($neededSystem eq $cur->{systemType}) { $rightType = 1; @@ -87,13 +89,15 @@ LOOP: foreach my $cur (@machines) { # one of the machine's lock files. my $slot = 0; while ($slot < $cur->{maxJobs}) { - my $slotLock = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot"; - open SLOTLOCK, ">>$slotLock" or die; - if (flock(SLOTLOCK, LOCK_EX | LOCK_NB)) { + my $slotLockFn = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot"; + $slotLock = new IO::Handle; + open $slotLock, ">>$slotLockFn" or die; + if (flock($slotLock, LOCK_EX | LOCK_NB)) { + utime undef, undef, $slotLock; $machine = $cur; last LOOP; } - close SLOTLOCK; + close $slotLock; $slot++; } }