1 |
diff -up mailman-2.1.9/Mailman/Queue/Runner.py.backup mailman-2.1.9/Mailman/Queue/Runner.py |
2 |
--- mailman-2.1.9/Mailman/Queue/Runner.py.backup 2009-10-20 14:33:03.000000000 +0200 |
3 |
+++ mailman-2.1.9/Mailman/Queue/Runner.py 2009-10-20 14:33:55.000000000 +0200 |
4 |
@@ -98,7 +98,7 @@ class Runner: |
5 |
# Ask the switchboard for the message and metadata objects |
6 |
# associated with this filebase. |
7 |
msg, msgdata = self._switchboard.dequeue(filebase) |
8 |
- except email.Errors.MessageParseError, e: |
9 |
+ except Exception, e: |
10 |
# It's possible to get here if the message was stored in the |
11 |
# pickle in plain text, and the metadata had a _parsemsg key |
12 |
# that was true, /and/ if the message had some bogosity in |
13 |
@@ -106,7 +106,8 @@ class Runner: |
14 |
# There's not much we can do (and we didn't even get the |
15 |
# metadata, so just log the exception and continue. |
16 |
self._log(e) |
17 |
- syslog('error', 'Ignoring unparseable message: %s', filebase) |
18 |
+ syslog('error', 'Skipping and preserving unparseable message: %s', filebase) |
19 |
+ self._switchboard.finish(filebase, preserve=True) |
20 |
continue |
21 |
try: |
22 |
self._onefile(msg, msgdata) |
23 |
@@ -121,9 +122,14 @@ class Runner: |
24 |
self._log(e) |
25 |
# Put a marker in the metadata for unshunting |
26 |
msgdata['whichq'] = self._switchboard.whichq() |
27 |
- new_filebase = self._shunt.enqueue(msg, msgdata) |
28 |
- syslog('error', 'SHUNTING: %s', new_filebase) |
29 |
- self._switchboard.finish(filebase) |
30 |
+ try: |
31 |
+ new_filebase = self._shunt.enqueue(msg, msgdata) |
32 |
+ syslog('error', 'SHUNTING: %s', new_filebase) |
33 |
+ self._switchboard.finish(filebase) |
34 |
+ except Exception, e: |
35 |
+ self._log(e) |
36 |
+ syslog('error','SHUNTING FAILED, preserving original entry: %s', filebase) |
37 |
+ self._switchboard.finish(filebase, preserve=True) |
38 |
# Other work we want to do each time through the loop |
39 |
Utils.reap(self._kids, once=True) |
40 |
self._doperiodic() |
41 |
diff -up mailman-2.1.9/Mailman/Queue/Switchboard.py.backup mailman-2.1.9/Mailman/Queue/Switchboard.py |
42 |
--- mailman-2.1.9/Mailman/Queue/Switchboard.py.backup 2009-10-20 14:33:22.000000000 +0200 |
43 |
+++ mailman-2.1.9/Mailman/Queue/Switchboard.py 2009-10-20 14:33:48.000000000 +0200 |
44 |
@@ -164,12 +164,24 @@ class Switchboard: |
45 |
msg = email.message_from_string(msg, Message.Message) |
46 |
return msg, data |
47 |
|
48 |
- def finish(self, filebase): |
49 |
+ def finish(self, filebase, preserve=False): |
50 |
bakfile = os.path.join(self.__whichq, filebase + '.bak') |
51 |
try: |
52 |
- os.unlink(bakfile) |
53 |
+ if preserve: |
54 |
+ psvfile = os.path.join(mm_cfg.SHUNTQUEUE_DIR, filebase + '.psv') |
55 |
+ omask = os.umask(0) # rwxrws--- |
56 |
+ try: |
57 |
+ try: |
58 |
+ os.mkdir(mm_cfg.SHUNTQUEUE_DIR, 0770) |
59 |
+ except OSError, e: |
60 |
+ if e.errno <> errno.EEXIST: raise |
61 |
+ finally: |
62 |
+ os.umask(omask) |
63 |
+ os.rename(bakfile, psvfile) |
64 |
+ else: |
65 |
+ os.unlink(bakfile) |
66 |
except EnvironmentError, e: |
67 |
- syslog('error', 'Failed to unlink backup file: %s', bakfile) |
68 |
+ syslog('error', 'Failed to unlink/preserve backup file: %s', bakfile) |
69 |
|
70 |
def files(self, extension='.pck'): |
71 |
times = {} |