Commit 440d0981 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use id rather than uuid for the message table, because it is more reliable, as...

Use id rather than uuid for the message table, because it is more reliable, as it works even if a node identification is not finished.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@221 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ee384fc2
......@@ -83,7 +83,7 @@ class ConnectionPool(object):
conn.lock()
try:
if not conn.pending() and \
not self.app.dispatcher.registered(conn.getUUID()):
not self.app.dispatcher.registered(id(conn)):
del self.connection_dict[conn.getUUID()]
conn.close()
logging.info('connection to storage node %s:%d closed',
......
......@@ -36,13 +36,13 @@ class Dispatcher(Thread):
def register(self, conn, msg_id, queue):
"""Register an expectation for a reply. Thanks to GIL, it is
safe not to use a lock here."""
key = (conn.getUUID(), msg_id)
key = (id(conn), msg_id)
self.message_table[key] = queue
def registered(self, uuid):
def registered(self, id):
"""Check if a connection is registered into message table."""
for conn_uuid, msg_id in self.message_table.iterkeys():
if uuid == conn_uuid:
for conn_id, msg_id in self.message_table.iterkeys():
if id == conn_id:
return True
return False
......
......@@ -28,7 +28,7 @@ class ClientEventHandler(EventHandler):
"""Redirect all received packet to dispatcher thread."""
dispatcher = self.dispatcher
# Send message to waiting thread
key = (conn.getUUID(), packet.getId())
key = (id(conn), packet.getId())
if key in dispatcher.message_table:
queue = dispatcher.message_table.pop(key)
queue.put((conn, packet))
......
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