Commit 9182462d authored by Grégory Wisniewski's avatar Grégory Wisniewski

Handle ECONNRESET from socket level.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@510 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 3d93441b
...@@ -24,7 +24,8 @@ from neo import protocol ...@@ -24,7 +24,8 @@ from neo import protocol
from neo.protocol import Packet, PacketMalformedError from neo.protocol import Packet, PacketMalformedError
from neo.event import IdleEvent from neo.event import IdleEvent
from neo.connector import ConnectorException, ConnectorTryAgainException, \ from neo.connector import ConnectorException, ConnectorTryAgainException, \
ConnectorInProgressException, ConnectorConnectionRefusedException ConnectorInProgressException, ConnectorConnectionRefusedException, \
ConnectorConnectionClosedException
from neo.util import dump from neo.util import dump
from neo.exception import OperationFailure from neo.exception import OperationFailure
...@@ -272,10 +273,14 @@ class Connection(BaseConnection): ...@@ -272,10 +273,14 @@ class Connection(BaseConnection):
self.write_buf = self.write_buf[n:] self.write_buf = self.write_buf[n:]
except ConnectorTryAgainException: except ConnectorTryAgainException:
pass pass
except ConnectorException: except ConnectorConnectionClosedException:
# connection resetted by peer
self.handler.connectionClosed(self) self.handler.connectionClosed(self)
self.close() self.close()
except ConnectorException:
# unhandled connector exception # unhandled connector exception
self.handler.connectionClosed(self)
self.close()
raise raise
def _addPacket(self, packet): def _addPacket(self, packet):
......
...@@ -105,6 +105,8 @@ class SocketConnector: ...@@ -105,6 +105,8 @@ class SocketConnector:
except socket.error, (err, errmsg): except socket.error, (err, errmsg):
if err == errno.EAGAIN: if err == errno.EAGAIN:
raise ConnectorTryAgainException raise ConnectorTryAgainException
if err == errno.ECONNRESET:
raise ConnectorConnectionClosedException
raise ConnectorException, 'send failed: %s:%s' % (err, errmsg) raise ConnectorException, 'send failed: %s:%s' % (err, errmsg)
def close(self): def close(self):
...@@ -115,5 +117,6 @@ registerConnectorHandler(SocketConnector) ...@@ -115,5 +117,6 @@ registerConnectorHandler(SocketConnector)
class ConnectorException(Exception): pass class ConnectorException(Exception): pass
class ConnectorTryAgainException(ConnectorException): pass class ConnectorTryAgainException(ConnectorException): pass
class ConnectorInProgressException(ConnectorException): pass class ConnectorInProgressException(ConnectorException): pass
class ConnectorConnectionClosedException(ConnectorException): pass
class ConnectorConnectionRefusedException(ConnectorException): pass class ConnectorConnectionRefusedException(ConnectorException): pass
...@@ -19,7 +19,7 @@ import logging ...@@ -19,7 +19,7 @@ import logging
from neo import protocol from neo import protocol
from neo.protocol import Packet, PacketMalformedError, UnexpectedPacketError, \ from neo.protocol import Packet, PacketMalformedError, UnexpectedPacketError, \
BrokenNotDisallowedError, NotReadyError BrokenNotDisallowedError, NotReadyError, ProtocolError
from neo.connection import ServerConnection from neo.connection import ServerConnection
from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICATION, \ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICATION, \
...@@ -362,6 +362,7 @@ class EventHandler(object): ...@@ -362,6 +362,7 @@ class EventHandler(object):
# Error packet handlers. # Error packet handlers.
# XXX: why answer a protocolError to another protocolError ?
handleNotReady = unexpectedPacket handleNotReady = unexpectedPacket
handleOidNotFound = unexpectedPacket handleOidNotFound = unexpectedPacket
handleSerialNotFound = unexpectedPacket handleSerialNotFound = unexpectedPacket
......
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