Commit d8a85899 authored by Vincent Pelletier's avatar Vincent Pelletier

Fix r2109 putting AnswerHasLock in the wrong queue

onStoreTimeout is called by poll thread, which causes a new local_var to be
implicitly created with a new queue (specific to poll thread, which isn't
supposed to have one).
To know the queue that should receive AnswerHasLock, reuse the one
registered to dispatcher to receive AnswerStoreObject.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2144 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent cefe62f3
...@@ -612,11 +612,13 @@ class Application(object): ...@@ -612,11 +612,13 @@ class Application(object):
return None return None
def onStoreTimeout(self, conn, msg_id, tid, oid): def onStoreTimeout(self, conn, msg_id, tid, oid):
# NOTE: this method is called from poll thread, don't use
# local_var !
# Stop expecting the timed-out store request.
queue = self.dispatcher.forget(conn, msg_id)
# Ask the storage if someone locks the object. # Ask the storage if someone locks the object.
# Shorten timeout to react earlier to an unresponding storage. # Shorten timeout to react earlier to an unresponding storage.
conn.ask(Packets.AskHasLock(tid, oid), timeout=5) conn.ask(Packets.AskHasLock(tid, oid), timeout=5, queue=queue)
# Stop expecting the timed-out store request.
self.dispatcher.forget(conn, msg_id)
return True return True
@profiler_decorator @profiler_decorator
......
...@@ -110,6 +110,7 @@ class Dispatcher: ...@@ -110,6 +110,7 @@ class Dispatcher:
queue.put((conn, ForgottenPacket(msg_id))) queue.put((conn, ForgottenPacket(msg_id)))
self.queue_dict[id(queue)] -= 1 self.queue_dict[id(queue)] -= 1
message_table[msg_id] = NOBODY message_table[msg_id] = NOBODY
return queue
@profiler_decorator @profiler_decorator
def registered(self, conn): def registered(self, conn):
......
...@@ -114,8 +114,9 @@ class DispatcherTests(unittest.TestCase): ...@@ -114,8 +114,9 @@ class DispatcherTests(unittest.TestCase):
MARKER = object() MARKER = object()
# Register an expectation # Register an expectation
self.dispatcher.register(conn, 1, queue) self.dispatcher.register(conn, 1, queue)
# ...and forget about it # ...and forget about it, returning registered queue
self.dispatcher.forget(conn, 1) forgotten_queue = self.dispatcher.forget(conn, 1)
self.assertTrue(queue is forgotten_queue, (queue, forgotten_queue))
# A ForgottenPacket must have been put in the queue # A ForgottenPacket must have been put in the queue
queue_conn, packet = queue.get(block=False) queue_conn, packet = queue.get(block=False)
self.assertTrue(isinstance(packet, ForgottenPacket), packet) self.assertTrue(isinstance(packet, ForgottenPacket), 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