Commit b5d78d1d authored by Vincent Pelletier's avatar Vincent Pelletier

Data pushed in queue is not opaque, as "forget" needs to know it.

The "data" parameter was meant to be used as an opaque type, but as
"forget" method needs to know its structure, stop pretending it's opaque.
This simplifies dispatch arguments a little bit.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2559 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 2fe481c8
......@@ -38,7 +38,7 @@ class BaseHandler(EventHandler):
def packetReceived(self, conn, packet):
"""Redirect all received packet to dispatcher thread."""
if packet.isResponse():
if not self.dispatcher.dispatch(conn, packet.getId(), (conn, packet)):
if not self.dispatcher.dispatch(conn, packet.getId(), packet):
raise ProtocolError('Unexpected response packet from %r: %r',
conn, packet)
else:
......
......@@ -54,15 +54,17 @@ class Dispatcher:
@giant_lock
@profiler_decorator
def dispatch(self, conn, msg_id, data):
"""Retrieve register-time provided queue, and put data in it."""
def dispatch(self, conn, msg_id, packet):
"""
Retrieve register-time provided queue, and put conn and packet in it.
"""
queue = self.message_table.get(id(conn), EMPTY).pop(msg_id, None)
if queue is None:
return False
elif queue is NOBODY:
return True
self._decrefQueue(queue)
queue.put(data)
queue.put((conn, packet))
return True
def _decrefQueue(self, queue):
......
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