diff options
| author | bwarsaw | 2001-05-11 05:25:07 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-05-11 05:25:07 +0000 |
| commit | 84ef9240b5d8b7d7e4bd7378250ce0fdb6dd07cd (patch) | |
| tree | 9261719e6e5d9b73e97ac708de5ee3a99fb3576c /bin/genaliases | |
| parent | 805bfa76168219cc2006f0b3805487b92fbb0451 (diff) | |
| download | mailman-84ef9240b5d8b7d7e4bd7378250ce0fdb6dd07cd.tar.gz mailman-84ef9240b5d8b7d7e4bd7378250ce0fdb6dd07cd.tar.zst mailman-84ef9240b5d8b7d7e4bd7378250ce0fdb6dd07cd.zip | |
main(): Before we write to the aliases.db file, we must drop an
exclusive advisory lock on it, so Postfix doesn't try to read the file
while we're updating it. For a discussion of why we have to do this
so cruftily, see Mailman/MTA/Postfix.py
Diffstat (limited to 'bin/genaliases')
| -rw-r--r-- | bin/genaliases | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/genaliases b/bin/genaliases index 951c3eabc..b71a74d1b 100644 --- a/bin/genaliases +++ b/bin/genaliases @@ -31,6 +31,7 @@ Options: import sys import getopt import dbhash +import fcntl import paths # path hacking from Mailman import Utils @@ -66,9 +67,13 @@ def main(): # we're doing it. lock = Postfix.makelock() lock.lock() + lockfp = None try: # Overwrite the current file contents, since we're going to be adding - # all new entries. + # all new entries. See the discussion in Mailman/MTA/Postfix.py for + # why we do the locking this way. + lockfp = open(Postfix.DBFILE) + fcntl.flock(lockfp.fileno(), fcntl.LOCK_EX) db = dbhash.open(Postfix.DBFILE, 'n') fp = open(Postfix.TEXTFILE, 'w') for listname in Utils.list_names(): @@ -77,6 +82,9 @@ def main(): db.sync() fp.close() finally: + if lockfp: + fcntl.flock(lockfp.fileno(), fcntl.LOCK_UN) + lockfp.close() lock.unlock(unconditionally=1) |
