preserve-libs: lock vardb for removeFromContents
authorZac Medico <zmedico@gentoo.org>
Mon, 16 May 2011 01:25:59 +0000 (18:25 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 May 2011 03:03:51 +0000 (20:03 -0700)
pym/portage/dbapi/vartree.py

index 8de794573a445c8e33dc6744944224014174d768..6ac161182368789854c4dc95f20c7173dde528db 100644 (file)
@@ -1523,10 +1523,14 @@ class dblink(object):
                                        unmerge_no_replacement)
                                if cpv_lib_map:
                                        self._remove_preserved_libs(cpv_lib_map)
-                                       for cpv, removed in cpv_lib_map.items():
-                                               if not self.vartree.dbapi.cpv_exists(cpv):
-                                                       continue
-                                               self.vartree.dbapi.removeFromContents(cpv, removed)
+                                       self.vartree.dbapi.lock()
+                                       try:
+                                               for cpv, removed in cpv_lib_map.items():
+                                                       if not self.vartree.dbapi.cpv_exists(cpv):
+                                                               continue
+                                                       self.vartree.dbapi.removeFromContents(cpv, removed)
+                                       finally:
+                                               self.vartree.dbapi.unlock()
 
                                plib_registry.store()
                        finally:
@@ -3455,12 +3459,19 @@ class dblink(object):
                                                # same cpv then the vdb entry no longer belongs
                                                # to it, so we'll have to get the slot and counter
                                                # from plib_registry._data instead.
+                                               self.vartree.dbapi.lock()
                                                try:
-                                                       slot, counter = self.vartree.dbapi.aux_get(
-                                                               cpv, ["SLOT", "COUNTER"])
-                                                       has_vdb_entry = True
-                                               except KeyError:
-                                                       pass
+                                                       try:
+                                                               slot, counter = self.vartree.dbapi.aux_get(
+                                                                       cpv, ["SLOT", "COUNTER"])
+                                                       except KeyError:
+                                                               pass
+                                                       else:
+                                                               has_vdb_entry = True
+                                                               self.vartree.dbapi.removeFromContents(
+                                                                       cpv, paths)
+                                               finally:
+                                                       self.vartree.dbapi.unlock()
 
                                        if not has_vdb_entry:
                                                # It's possible for previously unmerged packages
@@ -3484,8 +3495,6 @@ class dblink(object):
 
                                        remaining = [f for f in plib_dict[cpv] if f not in paths]
                                        plib_registry.register(cpv, slot, counter, remaining)
-                                       if has_vdb_entry:
-                                               self.vartree.dbapi.removeFromContents(cpv, paths)
 
                                plib_registry.store()
                        finally: