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-25 19:48:43 -0700
commitfe0ef947e1b70ea8fae1f5dfe53949afa65c0eac (patch)
tree223c5a2b0160f12a67513a39ac5a2ee78f0413ba /pym
parent6e6660af2244aed5bc2be5cb7b202e7b02e7058a (diff)
downloadportage-fe0ef947e1b70ea8fae1f5dfe53949afa65c0eac.tar.gz
portage-fe0ef947e1b70ea8fae1f5dfe53949afa65c0eac.tar.bz2
portage-fe0ef947e1b70ea8fae1f5dfe53949afa65c0eac.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 4e19b1065..8de794573 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -2309,7 +2309,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
@@ -2464,6 +2464,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()
@@ -2474,7 +2475,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
@@ -2482,7 +2483,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 3305aca49..2c40a346e 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):