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

[minion-cvs] Debug timeouts in response to testing.



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

Modified Files:
	MMTPServer.py 
Log Message:
Debug timeouts in response to testing.

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- MMTPServer.py	21 Dec 2002 01:54:23 -0000	1.5
+++ MMTPServer.py	29 Dec 2002 20:31:57 -0000	1.6
@@ -54,10 +54,12 @@
     #      in write events.
     # readers: map from fd to 'Connection' objects that are interested
     #      in read events.
+    # _timeout: the interval after which we drop open inactive connections.
     def __init__(self):
         """Create a new AsyncServer with no readers or writers."""
         self.writers = {}
         self.readers = {}
+        self._timeout = None
 
     def process(self, timeout):
         """If any relevant file descriptors become available within
@@ -137,6 +139,21 @@
         if r: del self.readers[fd]
         if w: del self.writers[fd]
 
+    def tryTimeout(self, now):
+        """Timeout any connection that is too old."""
+        if self._timeout is None:
+            return
+        # All connections older than 'cutoff' get purged.
+        cutoff = now - self._timeout
+        # Maintain a set of filenos for connections we've checked, so we don't
+        # check any more than once.
+        filenos = {}
+        for group in self.readers, self.writers:
+            for fd, con in group.items():
+                if filenos.has_key(fd): continue
+                con.tryTimeout(cutoff)
+                filenos[fd] = 1
+
 class Connection:
     "A connection is an abstract superclass for asynchronous channels"
     def handleRead(self):
@@ -712,7 +729,6 @@
        MMTPClientConnection, with a function to add new connections, and
        callbacks for message success and failure."""
     ##
-    # _timeout: the interval after which we drop open inactive connections.
     def __init__(self, config, tls):
         AsyncServer.__init__(self)
 
@@ -767,14 +783,3 @@
     def onMessageSent(self, msg, handle):
         pass
 
-    def tryTimeout(self, now):
-        """Timeout any connection that is too old."""
-        cutoff = now - self._timeout
-        filenos = {}
-        for fd, r in self.readers.items():
-            r.tryTimeout(self._timeout)
-            filenos[fd] = 1
-        for fd, w in self.writers.items():
-            if filenos.has_key(fd): continue
-            w.tryTimeout(self._timeout)
-            filenos[fd] = 0