def path_to_node(path):
node = path_node_map.get(path)
if node is None:
- node = LinkageMap._LibGraphNode(path, root)
+ node = LinkageMap._LibGraphNode(linkmap._obj_key(path))
alt_path_node = lib_graph.get(node)
if alt_path_node is not None:
node = alt_path_node
# Since preserved libraries can be consumers of other preserved
# libraries, use a graph to track consumer relationships.
plib_dict = self.vartree.dbapi._plib_registry.getPreservedLibs()
+ linkmap = self.vartree.dbapi._linkmap
lib_graph = digraph()
preserved_nodes = set()
preserved_paths = set()
def path_to_node(path):
node = path_node_map.get(path)
if node is None:
- node = LinkageMap._LibGraphNode(path, root)
+ node = LinkageMap._LibGraphNode(linkmap._obj_key(path))
alt_path_node = lib_graph.get(node)
if alt_path_node is not None:
node = alt_path_node
path_node_map[path] = node
return node
- linkmap = self.vartree.dbapi._linkmap
for cpv, plibs in plib_dict.items():
for f in plibs:
path_cpv_map[f] = cpv
"""Helper class used as _obj_properties keys for objects."""
- __slots__ = ("__weakref__", "_key")
+ __slots__ = ("_key",)
def __init__(self, obj, root):
"""
class _LibGraphNode(_ObjectKey):
__slots__ = ("alt_paths",)
- def __init__(self, obj, root):
- LinkageMapELF._ObjectKey.__init__(self, obj, root)
+ def __init__(self, key):
+ """
+ Create a _LibGraphNode from an existing _ObjectKey.
+ This re-uses the _key attribute in order to avoid repeating
+ any previous stat calls, which helps to avoid potential race
+ conditions due to inconsistent stat results when the
+ file system is being modified concurrently.
+ """
+ self._key = key._key
self.alt_paths = set()
def __str__(self):