summaryrefslogtreecommitdiff
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorbwarsaw2001-07-06 05:37:45 +0000
committerbwarsaw2001-07-06 05:37:45 +0000
commit287aee39034c8c5c5f73dbaa0d3d381712d07997 (patch)
treecc0ff3efc694cfa744e40caa87a11d329d77a43b /Mailman/Utils.py
parent97967ae4b24fee20f9727d0f71a488343918b93e (diff)
downloadmailman-287aee39034c8c5c5f73dbaa0d3d381712d07997.tar.gz
mailman-287aee39034c8c5c5f73dbaa0d3d381712d07997.tar.zst
mailman-287aee39034c8c5c5f73dbaa0d3d381712d07997.zip
Diffstat (limited to 'Mailman/Utils.py')
-rw-r--r--Mailman/Utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index 7fb4f75d4..a5117fcec 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -30,6 +30,7 @@ import random
import urlparse
import sha
import errno
+import time
from string import whitespace as WHITESPACE
from mimelib.MsgReader import MsgReader
@@ -678,3 +679,21 @@ def get_domain():
return host
else:
return mm_cfg.DEFAULT_HOST_NAME
+
+
+
+# This algorithm crafts a guaranteed unique message-id. The theory here is
+# that pid+listname+host will distinguish the message-id for every process on
+# the system, except when process ids wrap around. To further distinguish
+# message-ids, we prepend the integral time in seconds since the epoch. It's
+# still possible that we'll vend out more than one such message-id per second,
+# so we prepend a monotonically incrementing serial number. It's highly
+# unlikely that within a single second, there'll be a pid wraparound.
+_serial = 0
+def unique_message_id(mlist):
+ global _serial
+ msgid = '<mailman.%d.%d.%d.%s@%s>' % (
+ _serial, time.time(), os.getpid(),
+ mlist.internal_name(), mlist.host_name)
+ _serial += 1
+ return msgid