For the "blockers" parameter that's passed into the dblink constructor
authorZac Medico <zmedico@gentoo.org>
Fri, 9 May 2008 04:19:22 +0000 (04:19 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 9 May 2008 04:19:22 +0000 (04:19 -0000)
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
pym/portage.py

index 4c6b76dddd2ee92c6657c58fd7dc45d97efd3567..fc6a687a99f80ec683f0917b39e2cf13371cbc9b 100755 (executable)
@@ -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:
index 4bb4cbca6525c8261ec4d353f2e7a26f4d931f08..2ee750e52bf51ce6dd05fcbd54ffba5dbf7adac7 100644 (file)
@@ -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: