From cb15f13431e8433eda8b25b178e3b48b1b02de36 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Thu, 3 May 2001 21:18:25 +0000 Subject: main(): Add an explicit call to sys.exit() in the sigterm_handler() so that race conditions can't trick us into trying to Save() when we don't have the list lock. --- Mailman/Cgi/admindb.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py index cc061be26..72680ed9e 100644 --- a/Mailman/Cgi/admindb.py +++ b/Mailman/Cgi/admindb.py @@ -16,6 +16,7 @@ """Produce and process the pending-approval items for a list.""" +import sys import os import types import cgi @@ -75,18 +76,27 @@ def main(): doc = Document() doc.set_language(mlist.preferred_language) - # Lock the list for the next operation. 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. + # 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. # - # Also, see the comment in admin.py about the need for the signal handler. + # 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) + realname = mlist.real_name if not cgidata.keys(): # If this is not a form submission (i.e. there are no keys in the -- cgit v1.2.3-70-g09d2