qmemman: make memory request handling more defensive
If getting memory for new VM fails for any reason, make sure that global lock will be released. Otherwise qmemman will stop functioning at all. QubesOS/qubes-issues#1636
This commit is contained in:
parent
5546d679c0
commit
0121cb2fd4
@ -175,6 +175,7 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler):
|
||||
self.log = logging.getLogger('qmemman.daemon.reqhandler')
|
||||
|
||||
got_lock = False
|
||||
try:
|
||||
# self.request is the TCP socket connected to the client
|
||||
while True:
|
||||
self.data = self.request.recv(1024).strip()
|
||||
@ -184,8 +185,6 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler):
|
||||
if got_lock:
|
||||
global force_refresh_domain_list
|
||||
force_refresh_domain_list = True
|
||||
global_lock.release()
|
||||
self.log.debug('global_lock released')
|
||||
return
|
||||
|
||||
# XXX something is wrong here: return without release?
|
||||
@ -204,8 +203,13 @@ class QMemmanReqHandler(SocketServer.BaseRequestHandler):
|
||||
resp = "FAIL\n"
|
||||
self.log.debug('resp={!r}'.format(resp))
|
||||
self.request.send(resp)
|
||||
|
||||
# XXX no release of lock?
|
||||
except BaseException as e:
|
||||
self.log.exception(
|
||||
"exception while handling request: {!r}".format(e))
|
||||
finally:
|
||||
if got_lock:
|
||||
global_lock.release()
|
||||
self.log.debug('global_lock released')
|
||||
|
||||
|
||||
def start_server(server):
|
||||
|
Loading…
Reference in New Issue
Block a user