From f4f5e76787acb7d05098d389092ac49d8334e1df Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Mon, 14 May 2001 09:56:03 +0000 Subject: [PATCH] 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 --- mozilla/config/mozLock.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/mozilla/config/mozLock.pm b/mozilla/config/mozLock.pm index cb9507a8f88..c19fcd32e70 100644 --- a/mozilla/config/mozLock.pm +++ b/mozilla/config/mozLock.pm @@ -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($) {