Commit f35d6393 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Update read_buf as soon as possible, remove a useless try/finally, .

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1702 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a0d9f25d
......@@ -259,6 +259,7 @@ class Connection(BaseConnection):
def analyse(self):
"""Analyse received data."""
while True:
# parse a packet
try:
packet = Packets.parse(self.read_buf)
if packet is None:
......@@ -266,7 +267,7 @@ class Connection(BaseConnection):
except PacketMalformedError, msg:
self.handler._packetMalformed(self, packet, msg)
return
self.read_buf = self.read_buf[len(packet):]
# Remove idle events, if appropriate packets were received.
for msg_id in (None, packet.getId()):
......@@ -274,7 +275,6 @@ class Connection(BaseConnection):
if event is not None:
self.em.removeIdleEvent(event)
try:
packet_type = packet.getType()
if packet_type == Packets.Ping:
# Send a pong notification
......@@ -283,8 +283,6 @@ class Connection(BaseConnection):
# Skip PONG packets, its only purpose is to drop IdleEvent
# generated upong ping.
self._queue.append(packet)
finally:
self.read_buf = self.read_buf[len(packet):]
def hasPendingMessages(self):
"""
......
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