This repository was archived by the owner on Jan 22, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020# MA 02110-1301 USA.
2121
2222import copy
23+ import threading
2324
2425import libvirt
2526import libxml2
2829import _util
2930from virtinst import _gettext as _
3031
32+ _xml_refs_lock = threading .Lock ()
3133_xml_refs = {}
34+
3235def _unref_doc (doc ):
3336 if not doc :
3437 return
3538
3639 idx = None
37- for n in _xml_refs :
38- if n == doc :
39- idx = n
40- break
4140
42- if not idx :
43- return
41+ try :
42+ _xml_refs_lock .acquire ()
43+
44+ for n in _xml_refs :
45+ if n == doc :
46+ idx = n
47+ break
4448
45- _xml_refs [idx ] = _xml_refs [idx ] - 1
46- if _xml_refs [idx ] == 0 :
47- idx .freeDoc ()
49+ if not idx :
50+ return
51+
52+ _xml_refs [idx ] = _xml_refs [idx ] - 1
53+ if _xml_refs [idx ] == 0 :
54+ idx .freeDoc ()
55+ finally :
56+ _xml_refs_lock .release ()
4857
4958def _ref_doc (doc ):
5059 if not doc :
5160 return
5261
53- idx = doc
54- for n in _xml_refs :
55- if n == doc :
56- idx = n
57- break
62+ try :
63+ _xml_refs_lock .acquire ()
64+
65+ idx = doc
66+ for n in _xml_refs :
67+ if n == doc :
68+ idx = n
69+ break
5870
59- refcount = _xml_refs .get (idx ) or 0
60- _xml_refs [idx ] = refcount + 1
71+ refcount = _xml_refs .get (idx ) or 0
72+ _xml_refs [idx ] = refcount + 1
73+ finally :
74+ _xml_refs_lock .release ()
6175
6276def _sanitize_libxml_xml (xml ):
6377 # Strip starting <?...> line
You can’t perform that action at this time.
0 commit comments