aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/MailList.py
diff options
context:
space:
mode:
authorbwarsaw <>2004-03-04 03:35:36 +0000
committerbwarsaw <>2004-03-04 03:35:36 +0000
commitfc558e4026969a9d549a771f9050deace0b25e17 (patch)
tree8d7526a1871fd69d8ffd530fca1885928deaaf2b /Mailman/MailList.py
parent582595bfd0f27a6ace0f1eae868f26136f036253 (diff)
downloadmailman2-fc558e4026969a9d549a771f9050deace0b25e17.tar.gz
mailman2-fc558e4026969a9d549a771f9050deace0b25e17.tar.xz
mailman2-fc558e4026969a9d549a771f9050deace0b25e17.zip
Load(), __fix_corrupt_pckfile(): We should only rotate the corrupt pickle
files when the list lock is held.
Diffstat (limited to '')
-rw-r--r--Mailman/MailList.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 969f90ef..68d2aae2 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -575,7 +575,7 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
self.__timestamp = mtime
return dict, None
- def Load(self, check_version=1):
+ def Load(self, check_version=True):
if not Utils.list_exists(self.internal_name()):
raise Errors.MMUnknownListError
# We first try to load config.pck, which contains the up-to-date
@@ -608,7 +608,26 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
raise Errors.MMCorruptListDatabaseError, e
# Now, if we didn't end up using the primary database file, we want to
# copy the fallback into the primary so that the logic in Save() will
- # still work. For giggles, we'll copy it to a safety backup.
+ # still work. For giggles, we'll copy it to a safety backup. Note we
+ # MUST do this with the underlying list lock acquired.
+ unlock = True
+ try:
+ try:
+ self.__lock.lock()
+ except LockFile.AlreadyLockedError:
+ unlock = False
+ self.__fix_corrupt_pckfile(file, pfile, plast, dfile, dlast)
+ finally:
+ if unlock:
+ self.__lock.unlock()
+ # Copy the loaded dictionary into the attributes of the current
+ # mailing list object, then run sanity check on the data.
+ self.__dict__.update(dict)
+ if check_version:
+ self.CheckVersion(dict)
+ self.CheckValues()
+
+ def __fix_corrupt_pckfile(self, file, pfile, plast, dfile, dlast):
if file == plast:
# Move aside any existing pickle file and delete any existing
# safety file. This avoids EPERM errors inside the shutil.copy()
@@ -637,12 +656,6 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
if e.errno <> errno.ENOENT: raise
shutil.copy(file, dfile)
shutil.copy(file, dfile + '.safety')
- # Copy the loaded dictionary into the attributes of the current
- # mailing list object, then run sanity check on the data.
- self.__dict__.update(dict)
- if check_version:
- self.CheckVersion(dict)
- self.CheckValues()
#