[Yum-devel] [PATCH] fix a race in _getRepos(). BZ 860022

Zdeněk Pavlas zpavlas at redhat.com
Wed Dec 19 13:01:32 UTC 2012


---
 yum/__init__.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 2a82f97..69cfd3c 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -672,7 +672,12 @@ class YumBase(depsolve.Depsolve):
 
     def _getRepos(self, thisrepo=None, doSetup = False):
         """ For each enabled repository set up the basics of the repository. """
-        if hasattr(self, 'prerepoconf'):
+
+        # Anaconda calls this in multiple threads, without proper locking.
+        # Make sure test-and-delete of 'preconf' attribute is atomic.
+        # BZ 860022.
+        prerepoconf = self.__dict__.pop('prerepoconf', None)
+        if prerepoconf:
             self.conf # touch the config class first
 
             self.getReposFromConfig()
@@ -681,11 +686,8 @@ class YumBase(depsolve.Depsolve):
         # .getReposFromConfig() recurses back into this function but only once.
         # This means that we have two points on the stack leaving the above call
         # but only one of them can do the repos setup. BZ 678043.
-        if hasattr(self, 'prerepoconf'):
+        if prerepoconf:
             # Recursion
-            prerepoconf = self.prerepoconf
-            del self.prerepoconf
-
             self.repos.setProgressBar(prerepoconf.progressbar,
                                       prerepoconf.multi_progressbar)
             self.repos.callback = prerepoconf.callback
-- 
1.7.4.4



More information about the Yum-devel mailing list