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:
parent
2eba4c1c15
commit
eb6755e93c
@ -76,21 +76,25 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler):
|
|||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
global additional_balance_delay
|
global additional_balance_delay
|
||||||
|
got_lock = False
|
||||||
# self.request is the TCP socket connected to the client
|
# self.request is the TCP socket connected to the client
|
||||||
while True:
|
while True:
|
||||||
self.data = self.request.recv(1024).strip()
|
self.data = self.request.recv(1024).strip()
|
||||||
if len(self.data) == 0:
|
if len(self.data) == 0:
|
||||||
print 'EOF'
|
print 'EOF'
|
||||||
|
if got_lock:
|
||||||
|
global_lock.release()
|
||||||
return
|
return
|
||||||
if self.data == "DONE":
|
if got_lock:
|
||||||
|
print 'Second request over qmemman.sock ?'
|
||||||
return
|
return
|
||||||
global_lock.acquire()
|
global_lock.acquire()
|
||||||
|
got_lock = True
|
||||||
if system_state.do_balloon(int(self.data)):
|
if system_state.do_balloon(int(self.data)):
|
||||||
resp = "OK\n"
|
resp = "OK\n"
|
||||||
additional_balance_delay = 5
|
additional_balance_delay = 5
|
||||||
else:
|
else:
|
||||||
resp = "FAIL\n"
|
resp = "FAIL\n"
|
||||||
global_lock.release()
|
|
||||||
self.request.send(resp)
|
self.request.send(resp)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user