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