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