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

Handler switcher may have to switch more than on handler at time.

Typical case:

- Handler H1 is set
- Send request R1
- Request switch to handler H2 (delayed)
- Request switch to handler H3 (delayed)
- Receive answer A1
- H2 must be discarded and H3 applied on the connection

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1994 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 521d36d3
...@@ -108,16 +108,16 @@ class HandlerSwitcher(object): ...@@ -108,16 +108,16 @@ class HandlerSwitcher(object):
klass = request_dict.pop(msg_id, None) klass = request_dict.pop(msg_id, None)
if klass and isinstance(packet, klass) or packet.isError(): if klass and isinstance(packet, klass) or packet.isError():
handler.packetReceived(self._connection, packet) handler.packetReceived(self._connection, packet)
# apply a pending handler if no more answers are pending
if len(self._pending) > 1 and not request_dict:
del self._pending[0]
logging.debug('Apply handler %r', self._pending[0][1])
else: else:
logging.error('Unexpected answer: %r', packet) logging.error('Unexpected answer: %r', packet)
notification = Packets.Notify('Unexpected answer: %r' % packet) notification = Packets.Notify('Unexpected answer: %r' % packet)
self._connection.notify(notification) self._connection.notify(notification)
self._connection.abort() self._connection.abort()
handler.peerBroken(self._connection) handler.peerBroken(self._connection)
# apply a pending handler if no more answers are pending
while len(self._pending) > 1 and not self._pending[0][0]:
del self._pending[0]
logging.debug('Apply handler %r', self._pending[0][1])
def setHandler(self, handler): def setHandler(self, handler):
if len(self._pending) == 1 and not self._pending[0][0]: if len(self._pending) == 1 and not self._pending[0][0]:
......
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