[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Minor fixups



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

Modified Files:
	EventStats.py HashLog.py MMTPServer.py 
Log Message:
Minor fixups

Index: EventStats.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/EventStats.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- EventStats.py	13 Jul 2003 03:45:35 -0000	1.7
+++ EventStats.py	15 Jul 2003 04:41:18 -0000	1.8
@@ -16,7 +16,11 @@
 
 # _EVENTS: a list of all recognized event types.
 _EVENTS = [ 'ReceivedPacket',
-           
+
+            'ReceivedConnection',
+
+            'AttemptedConnect', 'SuccessfulConnect', 'FailedConnect',
+
             'AttemptedRelay', 'SuccessfulRelay',
             'FailedRelay', 'UnretriableRelay',
            
@@ -51,6 +55,20 @@
     def receivedPacket(self, arg=None):
         """Called whenever a packet is received via MMTP."""
         self._log("ReceivedPacket", arg)
+    def receivedConnection(self, arg=None):
+        """DOCDOC"""
+        self._log("ReceivedConnection", arg)
+
+    def attemptedConnect(self, arg=None):
+        """DOCDOC"""
+        self._log("AttemptedConnect", arg)
+    def successfulConnect(self, arg=None):
+        """DOCDOC"""
+        self._log("SuccessfulConnect", arg)
+    def failedConnect(self, arg=None):
+        """DOCDOC"""
+        self._log("FailedConnect", arg)
+
     def attemptedRelay(self, arg=None):
         """Called whenever we attempt to relay a packet via MMTP."""
         self._log("AttemptedRelay", arg)

Index: HashLog.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/HashLog.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- HashLog.py	13 Jul 2003 03:45:35 -0000	1.20
+++ HashLog.py	15 Jul 2003 04:41:18 -0000	1.21
@@ -133,6 +133,15 @@
 
         LOG.debug("Opening database %s for packet digests", filename)
         self.log = anydbm.open(filename, 'c')
+        if not hasattr(self.log, 'sync'):
+            if hasattr(self.log, '_commit'):
+                # Workaround for dumbdbm to allow syncing. (Standard in 
+                # Python 2.3.)
+                self.log.sync = self.log._commit
+            else:
+                # Otherwise, force a no-op sync method.
+                self.log.sync = lambda : None
+
         if isinstance(self.log, dumbdbm._Database):
             LOG.warn("Warning: logging packet digests to a flat file.")
         try:
@@ -140,7 +149,7 @@
                 raise MixFatalError("Log KEYID does not match current KEYID")
         except KeyError:
             self.log["KEYID"] = keyid
-            if hasattr(self.log, 'sync'): self.log.sync()
+            self.log.sync()
 
         # Scan the journal file
         self.journalFileName = filename+"_jrnl"
@@ -197,8 +206,7 @@
             self.__lock.acquire()
             for hash in self.journal.keys():
                 self.log[hash] = "1"
-            if hasattr(self.log, "sync"):
-                self.log.sync()
+            self.log.sync()
             os.close(self.journalFile)
             self.journalFile = os.open(self.journalFileName,
                        _JOURNAL_OPEN_FLAGS|os.O_TRUNC, 0600)

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- MMTPServer.py	15 Jul 2003 01:57:12 -0000	1.45
+++ MMTPServer.py	15 Jul 2003 04:41:18 -0000	1.46
@@ -597,6 +597,8 @@
         SimpleTLSConnection.__init__(self, sock, tls, 1,
                                      "%s:%s"%sock.getpeername())
         
+        EventStats.log.receivedConnection() #FFFF addr
+
         self.messageConsumer = consumer
         self.junkCallback = lambda : None
         self.rejectCallback = lambda : None
@@ -810,7 +812,8 @@
         self.finishedCallback = finishedCallback
         self.protocol = None
         self._curMessage = self._curHandle = None
-        
+
+        EventStats.log.attemptedConnect() #FFFF addr        
         debug("Opening client connection to %s", self.address)
 
     def isActive(self):
@@ -854,6 +857,8 @@
         else:
             debug("KeyID is valid from %s", self.address)
 
+        EventStats.log.successfulConnect()
+
         self.beginWrite("MMTP %s\r\n"%(",".join(self.PROTOCOL_VERSIONS)))
         self.finished = self.__sentProtocol
 
@@ -974,6 +979,8 @@
             statFn = EventStats.log.failedRelay
         else:
             statFn = EventStats.log.unretriableRelay
+        if self.finished is self.__setupFinished:
+            EventStats.log.failedConnect() #FFFF addr
         if self._curHandle is not None:
             self._curHandle.failed(retriable)
             statFn()
@@ -1095,6 +1102,7 @@
         except socket.error, e:
             LOG.error("Unexpected socket error connecting to %s:%s: %s",
                       ip, port, e)
+            EventStats.log.failedConnect() #FFFF addr
             for m in self.messageList:
                 try:
                     m.failed(1)