summaryrefslogtreecommitdiff
path: root/Mailman/LockFile.py
diff options
context:
space:
mode:
authorbwarsaw2000-06-14 05:03:56 +0000
committerbwarsaw2000-06-14 05:03:56 +0000
commit8d68b5e602a5a9221d905c49c00acecd87ea61a7 (patch)
tree6b4dbe96b071625c1a7c99dec9bbe99e82f714be /Mailman/LockFile.py
parent7c7d514cbccc96ffde7b17dd930735f0616ad5c5 (diff)
downloadmailman-8d68b5e602a5a9221d905c49c00acecd87ea61a7.tar.gz
mailman-8d68b5e602a5a9221d905c49c00acecd87ea61a7.tar.zst
mailman-8d68b5e602a5a9221d905c49c00acecd87ea61a7.zip
Diffstat (limited to 'Mailman/LockFile.py')
-rw-r--r--Mailman/LockFile.py32
1 files changed, 12 insertions, 20 deletions
diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py
index c599e066e..39b1cd1c7 100644
--- a/Mailman/LockFile.py
+++ b/Mailman/LockFile.py
@@ -251,15 +251,6 @@ class LockFile:
self.__writelog('unexpected link error: %s' % e)
os.unlink(self.__tmpfname)
raise
- elif self.__linkcount() == 1:
- # We've hit a race window. Proc1 is in the middle of
- # unlocking and has removed their tmpfname, leaving
- # lockfile with a link count of one. Proc2's os.link()
- # above fails w/EEXIST but the linkcount will be 1. Even
- # if multiple ProcN's attempt to claim the lock while
- # Proc1 is unlocking, linkcount can never be > 2. We'll
- # just try again later.
- self.__writelog('hit proc1 unlock race condition')
elif self.__linkcount() <> 2:
# Somebody's messin' with us! Log this, and try again
# later. TBD: should we raise an exception?
@@ -300,17 +291,17 @@ class LockFile:
islocked = self.locked()
if not islocked and not unconditionally:
raise NotLockedError
- # Remove our tempfile
- try:
- os.unlink(self.__tmpfname)
- except OSError, e:
- if e.errno <> errno.ENOENT: raise
# If we owned the lock, remove the global file, relinquishing it.
if islocked:
try:
os.unlink(self.__lockfile)
except OSError, e:
if e.errno <> errno.ENOENT: raise
+ # Remove our tempfile
+ try:
+ os.unlink(self.__tmpfname)
+ except OSError, e:
+ if e.errno <> errno.ENOENT: raise
self.__writelog('unlocked')
def locked(self):
@@ -399,21 +390,22 @@ class LockFile:
self.__touch(self.__lockfile)
except OSError, e:
if e.errno <> errno.EPERM: raise
+ # Get the name of the old winner's temp file.
+ winner = self.__read()
+ # Remove the global lockfile, which actually breaks the lock.
+ try:
+ os.unlink(self.__lockfile)
+ except OSError, e:
+ if e.errno <> errno.ENOENT: raise
# Try to remove the old winner's temp file, since we're assuming the
# winner process has hung or died. Don't worry too much if we can't
# unlink their temp file -- this doesn't wreck the locking algorithm,
# but will leave temp file turds laying around, a minor inconvenience.
- winner = self.__read()
try:
if winner:
os.unlink(winner)
except OSError, e:
if e.errno <> errno.ENOENT: raise
- # Now remove the global lockfile, which actually breaks the lock.
- try:
- os.unlink(self.__lockfile)
- except OSError, e:
- if e.errno <> errno.ENOENT: raise
def __sleep(self):
interval = random.random() * 2.0 + 0.01