diff options
| author | bwarsaw | 2000-05-08 22:31:32 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-05-08 22:31:32 +0000 |
| commit | b462d62cc1f47677a7d371f4c751afe2c36296be (patch) | |
| tree | e808988d711c32231bcf17c6a7af1206c7201bef | |
| parent | e12f19aed4bf846103ea47be08158fe36d207643 (diff) | |
| download | mailman-b462d62cc1f47677a7d371f4c751afe2c36296be.tar.gz mailman-b462d62cc1f47677a7d371f4c751afe2c36296be.tar.zst mailman-b462d62cc1f47677a7d371f4c751afe2c36296be.zip | |
Robustification of posting. If any of the following fails -- the list
name is missing or bogus, or the list lock cannot be acquired within
the LIST_LOCK_TIMEOUT time frame -- the message is enqueued for
qrunner to try again later. Previously, the message was simply lost!
If DeliverToUser() returns a true value, then this means the message
delivery was not completed, and again, the message is enqueued.
| -rwxr-xr-x | scripts/mailowner | 38 | ||||
| -rwxr-xr-x | scripts/owner | 38 |
2 files changed, 56 insertions, 20 deletions
diff --git a/scripts/mailowner b/scripts/mailowner index 434a5aa17..68e577105 100755 --- a/scripts/mailowner +++ b/scripts/mailowner @@ -29,10 +29,10 @@ import sys import mimetools import paths - from Mailman import mm_cfg from Mailman import MailList from Mailman import Message +from Mailman import Errors from Mailman.Handlers import HandlerAPI from Mailman.Bouncers import BouncerAPI from Mailman.Logging.Utils import LogStdErr @@ -43,9 +43,24 @@ LogStdErr('error', 'post') def main(): - # Only let one program per list run at any one time. TBD: This *can* - # fail, and should send back an error message when it does. - mlist = MailList.MailList(sys.argv[1]) + try: + listname = sys.argv[1] + except IndexError: + sys.stderr.write('Mailman error: mailowner got no listname.\n') + sys.exit(1) + try: + mlist = MailList.MailList(listname, lock=0) + except Errors.MMListError, e: + sys.stderr.write('Mailman error: mailowner got bad listname: %s\n%s' % + (listname, e)) + sys.exit(1) + # Try to obtain the mailing list lock. If that fails, enqueue the message + # for delivery by the qrunner cron job. + try: + mlist.Lock(timeout=mm_cfg.LIST_LOCK_TIMEOUT) + except LockFile.TimeOutError: + msg.Enqueue(mlist) + return try: s = StringIO(sys.stdin.read()) msg = mimetools.Message(s) @@ -55,12 +70,15 @@ def main(): # okay, no bounces were detected, but we have to convert this # mimetools.Message thingie to one of our OutgoingMessages. msg = Message.OutgoingMessage(s.getvalue()) - msg.recips = mlist.owner[:] - # for debugging purposes -## msg.recips.append(mm_cfg.MAILMAN_OWNER) - # flag this message as coming to the -admin address - msg.toadmin = 1 - HandlerAPI.DeliverToUser(mlist, msg) + recips = mlist.owner[:] + # debugging + #recips.append(mm_cfg.MAILMAN_OWNER) + msgdata = {'recips' : recips, + 'toadmin': 1, + } + enqueue = HandlerAPI.DeliverToUser(mlist, msg, msgdata) + if enqueue: + msg.Enqueue(mlist, newdata=msgdata) finally: mlist.Save() mlist.Unlock() diff --git a/scripts/owner b/scripts/owner index 434a5aa17..68e577105 100755 --- a/scripts/owner +++ b/scripts/owner @@ -29,10 +29,10 @@ import sys import mimetools import paths - from Mailman import mm_cfg from Mailman import MailList from Mailman import Message +from Mailman import Errors from Mailman.Handlers import HandlerAPI from Mailman.Bouncers import BouncerAPI from Mailman.Logging.Utils import LogStdErr @@ -43,9 +43,24 @@ LogStdErr('error', 'post') def main(): - # Only let one program per list run at any one time. TBD: This *can* - # fail, and should send back an error message when it does. - mlist = MailList.MailList(sys.argv[1]) + try: + listname = sys.argv[1] + except IndexError: + sys.stderr.write('Mailman error: mailowner got no listname.\n') + sys.exit(1) + try: + mlist = MailList.MailList(listname, lock=0) + except Errors.MMListError, e: + sys.stderr.write('Mailman error: mailowner got bad listname: %s\n%s' % + (listname, e)) + sys.exit(1) + # Try to obtain the mailing list lock. If that fails, enqueue the message + # for delivery by the qrunner cron job. + try: + mlist.Lock(timeout=mm_cfg.LIST_LOCK_TIMEOUT) + except LockFile.TimeOutError: + msg.Enqueue(mlist) + return try: s = StringIO(sys.stdin.read()) msg = mimetools.Message(s) @@ -55,12 +70,15 @@ def main(): # okay, no bounces were detected, but we have to convert this # mimetools.Message thingie to one of our OutgoingMessages. msg = Message.OutgoingMessage(s.getvalue()) - msg.recips = mlist.owner[:] - # for debugging purposes -## msg.recips.append(mm_cfg.MAILMAN_OWNER) - # flag this message as coming to the -admin address - msg.toadmin = 1 - HandlerAPI.DeliverToUser(mlist, msg) + recips = mlist.owner[:] + # debugging + #recips.append(mm_cfg.MAILMAN_OWNER) + msgdata = {'recips' : recips, + 'toadmin': 1, + } + enqueue = HandlerAPI.DeliverToUser(mlist, msg, msgdata) + if enqueue: + msg.Enqueue(mlist, newdata=msgdata) finally: mlist.Save() mlist.Unlock() |
