Commit 1a18b15e authored by Grégory Wisniewski's avatar Grégory Wisniewski

Remove 'packet' argument from handler._packetMalformed.

At connection level, when packet parsing fails there is no packet instance
(in except block). As there is no meaning to log a packet when it is
malformed, remove this parameter from _packetMalformed().

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1703 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f35d6393
......@@ -265,7 +265,7 @@ class Connection(BaseConnection):
if packet is None:
break
except PacketMalformedError, msg:
self.handler._packetMalformed(self, packet, msg)
self.handler._packetMalformed(self, msg)
return
self.read_buf = self.read_buf[len(packet):]
......
......@@ -30,19 +30,11 @@ class EventHandler(object):
self.packet_dispatch_table = self.__initPacketDispatchTable()
self.error_dispatch_table = self.__initErrorDispatchTable()
def _packetMalformed(self, conn, packet, message='', *args):
def _packetMalformed(self, conn, message='', *args):
"""Called when a packet is malformed."""
args = (conn.getAddress()[0], conn.getAddress()[1], message)
if packet is None:
# if decoding fail, there's no packet instance
logging.error('malformed packet from %s:%d: %s', *args)
else:
logging.error('malformed packet %s from %s:%d: %s',
packet.getType(), *args)
response = protocol.protocolError(message)
if packet is not None:
conn.answer(response)
else:
conn.notify(response)
conn.abort()
self.peerBroken(conn)
......@@ -73,7 +65,7 @@ class EventHandler(object):
except UnexpectedPacketError, e:
self.__unexpectedPacket(conn, packet, *e.args)
except PacketMalformedError, e:
self._packetMalformed(conn, packet, *e.args)
self._packetMalformed(conn, *e.args)
except BrokenNodeDisallowedError:
conn.answer(protocol.brokenNodeDisallowedError('go away'))
conn.abort()
......
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