qmemman: fix locking

We want balance() to wait on a lock even after balloon() has finished,
until socket client has closed.
This commit is contained in:
Rafal Wojtczuk 2010-08-30 14:50:48 +02:00
parent 2eba4c1c15
commit eb6755e93c

View File

@ -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)