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

[minion-cvs] Patch to prevent an exception found by roger, or at lea...



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

Modified Files:
      Tag: mixminion-v0-0-3-patches
	MMTPServer.py 
Log Message:
Patch to prevent an exception found by roger, or at least make it easier to trace (backport)

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -d -r1.20 -r1.20.2.1
--- MMTPServer.py	20 Feb 2003 16:57:40 -0000	1.20
+++ MMTPServer.py	5 May 2003 02:52:09 -0000	1.20.2.1
@@ -655,6 +655,8 @@
            failCallback -- None, or a function of (msg, handle, retriable)
               to be called when messages can't be sent."""
 
+        assert len(messageList) == len(handleList)
+               
         # Generate junk before connecting to avoid timing attacks
         self.junk = [] #XXXX doc this field.
         for m in messageList:
@@ -682,6 +684,7 @@
         self.sentCallback = sentCallback
         self.failCallback = failCallback
         self.protocol = None
+        self._curMessage = self._curHandle = None
 
         debug("Opening client connection (fd %s)", self.fd)
 
@@ -736,14 +739,15 @@
         if not self.messageList:
             self.shutdown(0)
             return
-        msg = self.messageList[0]
+        msg = self._curMessage = self.messageList[0]
+        handle = self._curHandle = self.handleList[0]
+        del self.messageList[0]
+        del self.handleList[0]
         if msg == 'RENEGOTIATE':
-            del self.messageList[0]
             self.finished = self.beginNextMessage
             self.startRenegotiate()
             return
         elif msg == 'JUNK':
-            del self.messageList[0]
             msg = self.junk[0]
             del self.junk[0]
             if self.protocol == '0.1':
@@ -790,20 +794,21 @@
 
        debug("Received valid ACK for message from %s", self.address)
        if not self.isJunk:
-           justSent = self.messageList[0]
-           justSentHandle = self.handleList[0]
-           del self.messageList[0]
-           del self.handleList[0]
            if self.sentCallback is not None:
-               self.sentCallback(justSent, justSentHandle)
+               self.sentCallback(self._curMessage, self._curHandle)
+
+       self._curMessage = self._curHandle = None
 
        self.beginNextMessage()
 
     def handleFail(self, retriable):
         """Invoked when a message is not deliverable."""
         if self.failCallback is not None:
+            if self._curHandle is not None:
+                self.failCallback(self._curMessage,self._curHandle,retriable)
             for msg, handle in zip(self.messageList, self.handleList):
-                self.failCallback(msg,handle,retriable)
+                if handle is not None:
+                    self.failCallback(msg,handle,retriable)
 
 LISTEN_BACKLOG = 128
 class MMTPAsyncServer(AsyncServer):