Commit 21c09ad8 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Close the connection before calling the handler method, as it's name implies,

the connection is already closed when the method is triggered. This is fix a bug
where a readable poll event was always available in the event manager (when
doing a poll()) if the close method was never invoked, eg. when a exception is
raised in the connectionClosed method (like VerificationFailure).


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@862 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent d8db8d56
......@@ -283,26 +283,26 @@ class Connection(BaseConnection):
data = self.connector.receive()
if not data:
logging.info('Connection %r closed in recv', self.connector)
self.handler.connectionClosed(self)
self.close()
self.handler.connectionClosed(self)
return
self.read_buf += data
except ConnectorTryAgainException:
pass
except ConnectorConnectionRefusedException:
# should only occur while connecting
self.handler.connectionFailed(self)
self.close()
self.handler.connectionFailed(self)
except ConnectorConnectionClosedException:
# connection resetted by peer, according to the man, this error
# should not occurs but it seems it's false
logging.info('Connection reset by peer: %r', self.connector)
self.handler.connectionClosed(self)
self.close()
self.handler.connectionClosed(self)
except ConnectorException:
logging.info('Unknown connection error: %r', self.connector)
self.handler.connectionClosed(self)
self.close()
self.handler.connectionClosed(self)
# unhandled connector exception
raise
......@@ -323,13 +323,13 @@ class Connection(BaseConnection):
except ConnectorConnectionClosedException:
# connection resetted by peer
logging.info('Connection reset by peer: %r', self.connector)
self.handler.connectionClosed(self)
self.close()
self.handler.connectionClosed(self)
except ConnectorException:
logging.info('Unknown connection error: %r', self.connector)
# unhandled connector exception
self.handler.connectionClosed(self)
self.close()
self.handler.connectionClosed(self)
raise
def _addPacket(self, packet):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment