From 672d3fdd899af17b28ab6d92477d921801bb23af Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 9 May 2008 04:19:22 +0000 Subject: [PATCH] For the "blockers" parameter that's passed into the dblink constructor now, make it a callable since it really shouldn't be called until the vdb lock has been acquired. (trunk r10264) svn path=/main/branches/2.1.2/; revision=10265 --- bin/emerge | 22 +++++++++++++++++----- pym/portage.py | 6 +++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/emerge b/bin/emerge index 4c6b76ddd..fc6a687a9 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1147,7 +1147,8 @@ class FakeVartree(portage.vartree): user doesn't necessarily need write access to the vardb in cases where global updates are necessary (updates are performed when necessary if there is not a matching ebuild in the tree).""" - def __init__(self, real_vartree, portdb, db_keys, pkg_cache): + def __init__(self, real_vartree, portdb, + db_keys, pkg_cache, acquire_lock=1): self.root = real_vartree.root self.settings = real_vartree.settings mykeys = db_keys[:] @@ -1164,7 +1165,7 @@ class FakeVartree(portage.vartree): pass vdb_lock = None try: - if os.access(vdb_path, os.W_OK): + if acquire_lock and os.access(vdb_path, os.W_OK): vdb_lock = portage_locks.lockdir(vdb_path) real_dbapi = real_vartree.dbapi slot_counters = {} @@ -1671,7 +1672,7 @@ class BlockerDB(object): "vartree" : self._vartree, }} - def findInstalledBlockers(self, new_pkg): + def findInstalledBlockers(self, new_pkg, acquire_lock=0): blocker_cache = self._blocker_cache dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"] dep_check_trees = self._dep_check_trees @@ -1679,7 +1680,8 @@ class BlockerDB(object): stale_cache = set(blocker_cache) fake_vartree = \ FakeVartree(self._vartree, - self._portdb, Package.metadata_keys, {}) + self._portdb, Package.metadata_keys, {}, + acquire_lock=acquire_lock) vardb = fake_vartree.dbapi installed_pkgs = list(vardb) @@ -5683,12 +5685,22 @@ class MergeTask(object): self._spawned_pids = [] def _find_blockers(self, new_pkg): + """ + Returns a callable which should be called only when + the vdb lock has been acquired. + """ + def get_blockers(): + return self._find_blockers_with_lock(new_pkg, acquire_lock=0) + return get_blockers + + def _find_blockers_with_lock(self, new_pkg, acquire_lock=0): if self._opts_ignore_blockers.intersection(self.myopts): return None blocker_dblinks = [] for blocking_pkg in self._blocker_db[ - new_pkg.root].findInstalledBlockers(new_pkg): + new_pkg.root].findInstalledBlockers(new_pkg, + acquire_lock=acquire_lock): if new_pkg.slot_atom == blocking_pkg.slot_atom: continue if new_pkg.cpv == blocking_pkg.cpv: diff --git a/pym/portage.py b/pym/portage.py index 4bb4cbca6..2ee750e52 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -9311,7 +9311,11 @@ class dblink: return 1 # check for package collisions - blockers = self._blockers + blockers = None + if self._blockers is not None: + # This is only supposed to be called when + # the vdb is locked, like it is here. + blockers = self._blockers() if blockers is None: blockers = [] if True: -- 2.26.2