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): ...@@ -283,26 +283,26 @@ class Connection(BaseConnection):
data = self.connector.receive() data = self.connector.receive()
if not data: if not data:
logging.info('Connection %r closed in recv', self.connector) logging.info('Connection %r closed in recv', self.connector)
self.handler.connectionClosed(self)
self.close() self.close()
self.handler.connectionClosed(self)
return return
self.read_buf += data self.read_buf += data
except ConnectorTryAgainException: except ConnectorTryAgainException:
pass pass
except ConnectorConnectionRefusedException: except ConnectorConnectionRefusedException:
# should only occur while connecting # should only occur while connecting
self.handler.connectionFailed(self)
self.close() self.close()
self.handler.connectionFailed(self)
except ConnectorConnectionClosedException: except ConnectorConnectionClosedException:
# connection resetted by peer, according to the man, this error # connection resetted by peer, according to the man, this error
# should not occurs but it seems it's false # should not occurs but it seems it's false
logging.info('Connection reset by peer: %r', self.connector) logging.info('Connection reset by peer: %r', self.connector)
self.handler.connectionClosed(self)
self.close() self.close()
self.handler.connectionClosed(self)
except ConnectorException: except ConnectorException:
logging.info('Unknown connection error: %r', self.connector) logging.info('Unknown connection error: %r', self.connector)
self.handler.connectionClosed(self)
self.close() self.close()
self.handler.connectionClosed(self)
# unhandled connector exception # unhandled connector exception
raise raise
...@@ -323,13 +323,13 @@ class Connection(BaseConnection): ...@@ -323,13 +323,13 @@ class Connection(BaseConnection):
except ConnectorConnectionClosedException: except ConnectorConnectionClosedException:
# connection resetted by peer # connection resetted by peer
logging.info('Connection reset by peer: %r', self.connector) logging.info('Connection reset by peer: %r', self.connector)
self.handler.connectionClosed(self)
self.close() self.close()
self.handler.connectionClosed(self)
except ConnectorException: except ConnectorException:
logging.info('Unknown connection error: %r', self.connector) logging.info('Unknown connection error: %r', self.connector)
# unhandled connector exception # unhandled connector exception
self.handler.connectionClosed(self)
self.close() self.close()
self.handler.connectionClosed(self)
raise raise
def _addPacket(self, packet): 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