From eb6755e93c22258e759072db653629bc48e5fcf8 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Mon, 30 Aug 2010 14:50:48 +0200 Subject: [PATCH] qmemman: fix locking We want balance() to wait on a lock even after balloon() has finished, until socket client has closed. --- dom0/qmemman/qmemman_server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dom0/qmemman/qmemman_server.py b/dom0/qmemman/qmemman_server.py index 302333ec..73dd205f 100755 --- a/dom0/qmemman/qmemman_server.py +++ b/dom0/qmemman/qmemman_server.py @@ -76,21 +76,25 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler): def handle(self): global additional_balance_delay + got_lock = False # self.request is the TCP socket connected to the client while True: self.data = self.request.recv(1024).strip() if len(self.data) == 0: print 'EOF' + if got_lock: + global_lock.release() return - if self.data == "DONE": + if got_lock: + print 'Second request over qmemman.sock ?' return global_lock.acquire() + got_lock = True if system_state.do_balloon(int(self.data)): resp = "OK\n" additional_balance_delay = 5 else: resp = "FAIL\n" - global_lock.release() self.request.send(resp)