core: ensure that QubesDB connections are closed when disposing a VM collection
There are some circular dependencies (TemplateVM.appvms, NetVM.connected_vms, and probably more), which prevents garbage collector from cleaning them. Fixes QubesOS/qubes-issues#1380
This commit is contained in:
parent
a7b124d6da
commit
d38883833a
@ -307,6 +307,16 @@ class QubesVmCollection(dict):
|
||||
|
||||
def clear(self):
|
||||
self.log.debug('clear()')
|
||||
# Hack for releasing FDs, which otherwise would be leaked because of
|
||||
# circular dependencies on QubesVMs objects (so garbage collector
|
||||
# doesn't handle them). See #1380 for details
|
||||
for vm in self.values():
|
||||
try:
|
||||
if vm._qdb_connection:
|
||||
vm._qdb_connection.close()
|
||||
vm._qdb_connection = None
|
||||
except AttributeError:
|
||||
pass
|
||||
super(QubesVmCollection, self).clear()
|
||||
|
||||
def values(self):
|
||||
|
Loading…
Reference in New Issue
Block a user