diff options
| -rw-r--r-- | Mailman/Cgi/handle_opts.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/Mailman/Cgi/handle_opts.py b/Mailman/Cgi/handle_opts.py index d065b0d8e..0592f961d 100644 --- a/Mailman/Cgi/handle_opts.py +++ b/Mailman/Cgi/handle_opts.py @@ -18,8 +18,8 @@ import sys import os -import string import cgi +import signal from Mailman import mm_cfg from Mailman import Utils @@ -60,11 +60,11 @@ def main(): print doc.Format(bgcolor="#ffffff") return - listname = string.lower(parts[0]) + listname = parts[0].lower() user = parts[1] try: - mlist = MailList.MailList(listname) + mlist = MailList.MailList(listname, lock=0) except Errors.MMListError, e: doc.AddItem(Header(2, _("Error"))) doc.AddItem(Bold(_('No such list <em>%(listname)s</em>'))) @@ -72,10 +72,30 @@ def main(): syslog('error', 'No such list "%s": %s\n' % (listname, e)) return + # We need a signal handler to catch the SIGTERM that can come from Apache + # when the user hits the browser's STOP button. See the comment in + # admin.py for details. + # + # BAW: Strictly speaking, the list should not need to be locked just to + # read the request database. However the request database asserts that + # the list is locked in order to load it and it's not worth complicating + # that logic. + def sigterm_handler(signum, frame, mlist=mlist): + # Make sure the list gets unlocked... + mlist.Unlock() + # ...and ensure we exit, otherwise race conditions could cause us to + # enter MailList.Save() while we're in the unlocked state, and that + # could be bad! + sys.exit(0) + + mlist.Lock() try: + # Install the emergency shutdown signal handler + signal.signal(signal.SIGTERM, sigterm_handler) + process_form(mlist, user, doc) - finally: mlist.Save() + finally: mlist.Unlock() |
