diff options
| author | cotton | 1998-10-13 21:25:38 +0000 |
|---|---|---|
| committer | cotton | 1998-10-13 21:25:38 +0000 |
| commit | 2ca2f38983b38ee7cb75e50961e3ea02ecd45c87 (patch) | |
| tree | d53faadf2dc11ab2242c3fdd2c24e8be4eb5af65 /Mailman/OutgoingQueue.py | |
| parent | e8641a172f45b17b654332248994260a5041e867 (diff) | |
| download | mailman-2ca2f38983b38ee7cb75e50961e3ea02ecd45c87.tar.gz mailman-2ca2f38983b38ee7cb75e50961e3ea02ecd45c87.tar.zst mailman-2ca2f38983b38ee7cb75e50961e3ea02ecd45c87.zip | |
more stress tests of the queue!
bugfixes:
1) forgot to put import errno in previous checkin.
2) tempfile.mktemp() didn't suffice for creating unique
filenames with lots of concurrent processes going on,
so i made it set tempfile.template with the current pid
in it.
this has been tested with multiple concurrent contact_transport
processes together with a run_queue process -- with and without smtpd
listening on mailman's SMTPHOST.
the version of OutgoingQueue prior to these two checkins ran for
about a week on linux and Solaris without problem. when these
problems did creep up, they were harmless. they *could* have
caused failed deliveries, but it would be pretty darn unlikely.
scott
Diffstat (limited to 'Mailman/OutgoingQueue.py')
| -rw-r--r-- | Mailman/OutgoingQueue.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Mailman/OutgoingQueue.py b/Mailman/OutgoingQueue.py index faedc5654..0b82dbf61 100644 --- a/Mailman/OutgoingQueue.py +++ b/Mailman/OutgoingQueue.py @@ -36,7 +36,7 @@ # only one such process to happen at a time. # -import os, stat, tempfile, marshal, mm_cfg +import os, stat, tempfile, marshal, errno, mm_cfg TEMPLATE = "mm_q." # @@ -77,7 +77,7 @@ def processQueue(): full_fname = os.path.join(mm_cfg.DATA_DIR, file) # # we need to stat the file if it still exists (atomically, we - # can't use use os.path.exists then stat. + # can't just use use os.path.exists then stat it. # if it doesn't exist, it's been dequeued since we saw # it in the directory listing # @@ -112,11 +112,17 @@ def processQueue(): # # this function is used by any process that # attempts to deliver a message for the first time -# so the entry is set with the SUID bit. +# so the entry is set with the SUID bit. With all these +# concurrent processes calling this function, we can't quite +# trust mktemp() to generate a unique filename, and with the +# possibility of a q entry lasting longer than the pid generation +# cycle on the system we can't quite trust os.getpid() to return +# a unique filename either. but if we use getpid() in the +# template, then mktemp should always return a unique filename. # def enqueueMessage(the_sender, recip, text): tempfile.tempdir = mm_cfg.DATA_DIR - tempfile.template = TEMPLATE + tempfile.template = "%s%d." % (TEMPLATE, os.getpid()) fname = tempfile.mktemp() f = open(fname, "a+") os.chmod(fname, QF_MODE | stat.S_ISUID) # make sure this is set right off the bat |
