summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-14 18:56:39 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-14 18:56:39 -0700
commitdc36d802cc1eba7c3d818cebb77e947e930ec2ce (patch)
tree14cafaae8b01b155968e13d2796aee782ce3786c /pym
parent461564ae94ff936918eeaa18493bc1da3846796f (diff)
downloadportage-dc36d802cc1eba7c3d818cebb77e947e930ec2ce.tar.gz
portage-dc36d802cc1eba7c3d818cebb77e947e930ec2ce.tar.bz2
portage-dc36d802cc1eba7c3d818cebb77e947e930ec2ce.zip
_LibGraphNode: re-use the _key attribute
This allows us 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.
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py6
-rw-r--r--pym/portage/util/_dyn_libs/LinkageMapELF.py13
2 files changed, 13 insertions, 6 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 802253afc..d1905663d 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -2344,7 +2344,7 @@ class dblink(object):
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
@@ -2499,6 +2499,7 @@ class dblink(object):
# 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()
@@ -2509,7 +2510,7 @@ class dblink(object):
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
@@ -2517,7 +2518,6 @@ class dblink(object):
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
diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py
index fe86a7a89..fef75b62c 100644
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py
@@ -60,7 +60,7 @@ class LinkageMapELF(object):
"""Helper class used as _obj_properties keys for objects."""
- __slots__ = ("__weakref__", "_key")
+ __slots__ = ("_key",)
def __init__(self, obj, root):
"""
@@ -135,8 +135,15 @@ class LinkageMapELF(object):
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):