* Update the mtime on the lock file to make it easy to see when a slot
was last used.
This commit is contained in:
parent
cbc1f57b48
commit
096affb55b
1 changed files with 8 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use Fcntl ':flock';
|
use Fcntl ':flock';
|
||||||
use English '-no_match_vars';
|
use English '-no_match_vars';
|
||||||
|
use IO::Handle;
|
||||||
|
|
||||||
# General operation:
|
# General operation:
|
||||||
#
|
#
|
||||||
|
@ -79,6 +80,7 @@ flock(MAINLOCK, LOCK_EX) or die;
|
||||||
# Find a suitable system.
|
# Find a suitable system.
|
||||||
my $rightType = 0;
|
my $rightType = 0;
|
||||||
my $machine;
|
my $machine;
|
||||||
|
my $slotLock;
|
||||||
LOOP: foreach my $cur (@machines) {
|
LOOP: foreach my $cur (@machines) {
|
||||||
if ($neededSystem eq $cur->{systemType}) {
|
if ($neededSystem eq $cur->{systemType}) {
|
||||||
$rightType = 1;
|
$rightType = 1;
|
||||||
|
@ -87,13 +89,15 @@ LOOP: foreach my $cur (@machines) {
|
||||||
# one of the machine's lock files.
|
# one of the machine's lock files.
|
||||||
my $slot = 0;
|
my $slot = 0;
|
||||||
while ($slot < $cur->{maxJobs}) {
|
while ($slot < $cur->{maxJobs}) {
|
||||||
my $slotLock = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot";
|
my $slotLockFn = "$currentLoad/" . $cur->{systemType} . "-" . $cur->{hostName} . "-$slot";
|
||||||
open SLOTLOCK, ">>$slotLock" or die;
|
$slotLock = new IO::Handle;
|
||||||
if (flock(SLOTLOCK, LOCK_EX | LOCK_NB)) {
|
open $slotLock, ">>$slotLockFn" or die;
|
||||||
|
if (flock($slotLock, LOCK_EX | LOCK_NB)) {
|
||||||
|
utime undef, undef, $slotLock;
|
||||||
$machine = $cur;
|
$machine = $cur;
|
||||||
last LOOP;
|
last LOOP;
|
||||||
}
|
}
|
||||||
close SLOTLOCK;
|
close $slotLock;
|
||||||
$slot++;
|
$slot++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue