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

[minion-cvs] Remain constant in the face of network failure. (Bug fo...



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

Modified Files:
	MMTPServer.py 
Log Message:
Remain constant in the face of network failure. (Bug found by squirrel)

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/MMTPServer.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- MMTPServer.py	28 Sep 2003 04:12:29 -0000	1.51
+++ MMTPServer.py	1 Oct 2003 01:34:50 -0000	1.52
@@ -1125,14 +1125,16 @@
         try:
             # Is there an existing connection open to the right server?
             con = self.clientConByAddr[(ip,port,keyID)]
-            # If so, is that connection currently sending messages?
+        except KeyError:
+            pass
+        else:
+            # No exception: There is an existing connection.  But is that
+            # connection currently sending messages?
             if con.isActive():
                 LOG.debug("Queueing %s messages on open connection to %s",
                           len(deliverable), con.address)
                 con.addMessages(deliverable)
                 return
-        except KeyError:
-            pass
 
         try:
             # There isn't any connection to the right server. Open one...
@@ -1142,19 +1144,21 @@
                                      ip, port, keyID, deliverable,
                                      finishedCallback=finished,
                                      certCache=self.certificateCache)
-            con.register(self)
-            # ...and register it in clientConByAddr
-            assert addr == con.getAddr()
-            self.clientConByAddr[addr] = con
         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 con.messageList:
+            for m in deliverable:
                 try:
                     m.failed(1)
                 except AttributeError:
                     pass
+        else:
+            # No exception: We created the connection successfully.  
+            # Thus, register it in clientConByAddr
+            assert addr == con.getAddr()
+            con.register(self)
+            self.clientConByAddr[addr] = con
 
     def __clientFinished(self, addr):
         """Called when a client connection runs out of messages to send."""