aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-03-29 18:40:44 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-03-29 18:40:44 +0000
commit096affb55b06c1280df9ff6b1fd5111d5745b57a (patch)
treea0b9f7f661587f3af462907aad588a64493eabd9
parentcbc1f57b48dc9b8f0c679e004ee407d3cf27d5c5 (diff)
* Update the mtime on the lock file to make it easy to see when a slot
was last used.
-rwxr-xr-xscripts/build-remote.pl.in12
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/build-remote.pl.in b/scripts/build-remote.pl.in
index 03bceb884..7c2797f5d 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++;
}
}