[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Client-side pooling, locking, refactoring. (Untested)



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv31315/lib/mixminion/server

Modified Files:
	ServerMain.py 
Log Message:
Client-side pooling, locking, refactoring.  (Untested)

(Untested; use at your own risk!)

ClientMain:
        - Add basic locking functionality
        - Add a simple pool to hold messages when we've been asked to, or
          when we can't deliver them.
        - Add log to remember which SURBs we've used
        - Handle files that contain many SURBs
        - Refactor command-line argument parsing to minimize code duplication
        - Add SURB inspection command.

Common:
        - Add a succeedingMidnight function

Common, ServerMain:
        - Move Lockfile to Common

Packet:
        - Add support for multiple reply blocks in one file.



Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- ServerMain.py	5 Feb 2003 06:45:51 -0000	1.35
+++ ServerMain.py	6 Feb 2003 20:20:03 -0000	1.36
@@ -10,7 +10,6 @@
 
 __all__ = [ 'MixminonServer' ]
 
-import fcntl
 import getopt
 import os
 import sys
@@ -34,7 +33,7 @@
 from bisect import insort
 from mixminion.Common import LOG, LogStream, MixError, MixFatalError, ceilDiv,\
      createPrivateDir, formatBase64, formatTime, installSIGCHLDHandler, \
-     secureDelete, waitForChildren
+     Lockfile, secureDelete, waitForChildren
 
 class IncomingQueue(mixminion.server.ServerQueue.Queue):
     """A DeliveryQueue to accept packets from incoming MMTP connections,
@@ -386,10 +385,9 @@
 
         # Lock file.
         # FFFF Refactor this part into common?
-        self.lockFile = os.path.join(homeDir, "lock")
-        self.lockFD = os.open(self.lockFile, os.O_RDWR|os.O_CREAT, 0600)
+        self.lockFile = Lockfile(os.path.join(homeDir, "lock"))
         try:
-            fcntl.flock(self.lockFD, fcntl.LOCK_EX|fcntl.LOCK_NB)
+            self.lockFile.acquire()
         except IOError:
             raise MixFatalError("Another server seems to be running.")
 
@@ -568,9 +566,7 @@
         
         self.packetHandler.close()
         try:
-            os.unlink(self.lockFile)
-            fcntl.flock(self.lockFD, fcntl.LOCK_UN)
-            os.close(self.lockFD)
+            self.lockFile.release()
             os.unlink(self.pidFile)
         except OSError:
             pass