Try to leave as little time as possible between discovering the lockfile does not exist and creating a new one.

git-svn-id: svn://10.0.0.236/trunk@94875 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cls%seawood.org 2001-05-14 09:56:03 +00:00
parent 420bc20001
commit f4f5e76787

View File

@ -74,16 +74,22 @@ sub mozLock($) {
my ($inlockfile) = @_;
my ($lockhandle, $lockfile);
$lockfile = priv_abspath($inlockfile);
$lockcounter = 0;
while ( -e $lockfile && $lockcounter < $locklimit) {
$lockcounter++;
sleep(1);
}
die "$0: Could not get lockfile $lockfile.\nRemove $lockfile to clear up\n" if ($lockcounter >= $locklimit);
$lockhandle = new IO::File || die "Could not create filehandle for $lockfile: $!\n";
#print "LOCK: $lockfile\n";
open($lockhandle, ">$lockfile") || die "$lockfile: $!\n";
$lockhash{$lockfile} = $lockhandle;
$lockcounter = 0;
$lockhandle = new IO::File || die "Could not create filehandle for $lockfile: $!\n";
while ($lockcounter < $locklimit) {
if (! -e $lockfile) {
open($lockhandle, ">$lockfile") || die "$lockfile: $!\n";
$lockhash{$lockfile} = $lockhandle;
last;
}
$lockcounter++;
sleep($locksleep);
}
if ($lockcounter >= $locklimit) {
undef $lockhandle;
die "$0: Could not get lockfile $lockfile.\nRemove $lockfile to clear up\n";
}
}
sub mozUnlock($) {