qmemman: use try/finally to really release the lock
Currently not needed in practice, but a preparation for the next commit(s). QubesOS/qubes-issues#1389
This commit is contained in:
parent
6a99b0b2ba
commit
3eccc3a633
@ -93,22 +93,22 @@ class XS_Watcher:
|
|||||||
self.log.debug('acquiring global_lock')
|
self.log.debug('acquiring global_lock')
|
||||||
global_lock.acquire()
|
global_lock.acquire()
|
||||||
self.log.debug('global_lock acquired')
|
self.log.debug('global_lock acquired')
|
||||||
|
try:
|
||||||
|
for i in only_in_first_list(curr, self.watch_token_dict.keys()):
|
||||||
|
#new domain has been created
|
||||||
|
watch = WatchType(XS_Watcher.meminfo_changed, i)
|
||||||
|
self.watch_token_dict[i] = watch
|
||||||
|
self.handle.watch(get_domain_meminfo_key(i), watch)
|
||||||
|
system_state.add_domain(i)
|
||||||
|
|
||||||
for i in only_in_first_list(curr, self.watch_token_dict.keys()):
|
for i in only_in_first_list(self.watch_token_dict.keys(), curr):
|
||||||
#new domain has been created
|
#domain destroyed
|
||||||
watch = WatchType(XS_Watcher.meminfo_changed, i)
|
self.handle.unwatch(get_domain_meminfo_key(i), self.watch_token_dict[i])
|
||||||
self.watch_token_dict[i] = watch
|
self.watch_token_dict.pop(i)
|
||||||
self.handle.watch(get_domain_meminfo_key(i), watch)
|
system_state.del_domain(i)
|
||||||
system_state.add_domain(i)
|
finally:
|
||||||
|
global_lock.release()
|
||||||
for i in only_in_first_list(self.watch_token_dict.keys(), curr):
|
self.log.debug('global_lock released')
|
||||||
#domain destroyed
|
|
||||||
self.handle.unwatch(get_domain_meminfo_key(i), self.watch_token_dict[i])
|
|
||||||
self.watch_token_dict.pop(i)
|
|
||||||
system_state.del_domain(i)
|
|
||||||
|
|
||||||
global_lock.release()
|
|
||||||
self.log.debug('global_lock released')
|
|
||||||
|
|
||||||
system_state.do_balance()
|
system_state.do_balance()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user