[Neo-report] r2022 vincent - /trunk/neo/connection.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Apr 26 09:49:03 CEST 2010


Author: vincent
Date: Mon Apr 26 09:49:03 2010
New Revision: 2022

Log:
Fix a logical inversion in was_connected meaning.

"was_connected" actually meant "was_not_connected". To avoid using a
negation in variable name, fix its use and values it's set to.

Modified:
    trunk/neo/connection.py

Modified: trunk/neo/connection.py
==============================================================================
--- trunk/neo/connection.py [iso-8859-1] (original)
+++ trunk/neo/connection.py [iso-8859-1] Mon Apr 26 09:49:03 2010
@@ -448,14 +448,14 @@
     def pending(self):
         return self.connector is not None and self.write_buf
 
-    def _closure(self, was_connected=False):
+    def _closure(self, was_connected=True):
         assert self.connector is not None, self.whoSetConnector()
         handler = self.getHandler()
         self.close()
         if was_connected:
+            handler.connectionClosed(self)
+        else:
             handler.connectionFailed(self)
-        else:
-            handler.connectionClosed(self)
 
     @profiler_decorator
     def _recv(self):
@@ -466,7 +466,7 @@
             pass
         except ConnectorConnectionRefusedException:
             # should only occur while connecting
-            self._closure(was_connected=True)
+            self._closure(was_connected=False)
         except ConnectorConnectionClosedException:
             # connection resetted by peer, according to the man, this error
             # should not occurs but it seems it's false
@@ -585,10 +585,10 @@
                 self.connecting = False
                 self.getHandler().connectionCompleted(self)
         except ConnectorConnectionRefusedException:
-            self._closure(was_connected=True)
+            self._closure(was_connected=False)
         except ConnectorException:
             # unhandled connector exception
-            self._closure(was_connected=True)
+            self._closure(was_connected=False)
             raise
 
     def writable(self):
@@ -596,7 +596,7 @@
         if self.connecting:
             err = self.connector.getError()
             if err:
-                self._closure(was_connected=True)
+                self._closure(was_connected=False)
                 return
             else:
                 self.connecting = False





More information about the Neo-report mailing list