Update of /cvsroot/mailman/mailman/Mailman/Queue
In directory sc8-pr-cvs1:/tmp/cvs-serv20749

Modified Files:
        Switchboard.py 
Log Message:
SYNC_AFTER_WRITE: New flag which controls whether os.fsync() is called
on the file descriptor for data files after they've been written.  We
always flush the buffer, but sync'ing can be a huge performance hit.
Still, some sites might want to enable this for additional data
integrity.  It's disabled by default.

enqueue(): Return the newly calculated filebase.  This let's the shunt
message in Runner.py display the correct (new) filename.


Index: Switchboard.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Queue/Switchboard.py,v
retrieving revision 2.18
retrieving revision 2.19
diff -u -d -r2.18 -r2.19
--- Switchboard.py      19 Apr 2003 15:41:34 -0000      2.18
+++ Switchboard.py      12 Sep 2003 13:47:12 -0000      2.19
@@ -50,7 +50,20 @@
 # 20 bytes of all bits set, maximum sha.digest() value
 shamax = 0xffffffffffffffffffffffffffffffffffffffffL
 
-SAVE_MSGS_AS_PICKLES = 1
+try:
+    True, False
+except NameError:
+    True = 1
+    False = 0
+
+# This flag causes Mailman to fsync() the file after writing and flushing its
+# contents.  While this ensures the data is written to disk, avoiding data
+# loss, it is a huge performance killer.
+SYNC_AFTER_WRITE = False
+# This flag causes messages to be written as pickles (when True) or text files
+# (when False).  Pickles are more efficient because the message doesn't need
+# to be re-parsed every time it's unqueued, but pickles are not human readable.
+SAVE_MSGS_AS_PICKLES = True
 
 
 
@@ -127,6 +140,7 @@
         tmpfile = dbfile + '.tmp'
         self._ext_write(tmpfile, data)
         os.rename(tmpfile, dbfile)
+        return filebase
 
     def dequeue(self, filebase):
         # Calculate the .db and .msg filenames from the given filebase.
@@ -239,6 +253,10 @@
             else:
                 dict[attr] = repr(fval)
         marshal.dump(dict, fp)
+        # Make damn sure that the data we just wrote gets flushed to disk
+        fp.flush()
+        if SYNC_AFTER_WRITE:
+            os.fsync(fp.fileno())
         fp.close()
 
     def _ext_read(self, filename):
@@ -307,6 +325,10 @@
             os.umask(omask)
         for k, v in dict.items():
             print >> fp, '%s = %s' % (k, repr(v))
+        # Make damn sure that the data we just wrote gets flushed to disk
+        fp.flush()
+        if SYNC_AFTER_WRITE:
+            os.fsync(fp.fileno())
         fp.close()
 
     def _ext_read(self, filename):



_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to