fix rpm db4 error(9): bad file descriptor
authorGui Chen <gui.chen@intel.com>
Wed, 1 Feb 2012 08:43:29 +0000 (16:43 +0800)
committerGui Chen <gui.chen@intel.com>
Wed, 1 Feb 2012 08:43:29 +0000 (16:43 +0800)
this bug root causes many issues, including 'failed to unmap loop',
it's caused by the unclosed rpmdb in yum backend, which is closed
by self.ts.close() in this commit.
Besides, self.closeRpmDB will set self._ts to None, so its order
would be put in the back.

Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/imager/baseimager.py
plugins/backend/yumpkgmgr.py
plugins/backend/zypppkgmgr.py

index 6083cc8..12bc80f 100644 (file)
@@ -906,7 +906,6 @@ class BaseImageCreator(object):
             self._pkgs_content = pkg_manager.getAllContent()
             self._pkgs_license = pkg_manager.getPkgsLicense()
 
-            pkg_manager.closeRpmDB()
             pkg_manager.close()
             os.unlink(yum_conf)
 
index 2971f71..3cd01f9 100644 (file)
@@ -83,10 +83,13 @@ class Yum(BackendPlugin, yum.YumBase):
             os.unlink(self.conf.installroot + "/yum.conf")
         except:
             pass
-        self.closeRpmDB()
-        yum.YumBase.close(self)
+
+        if self.ts:
+            self.ts.close()
         self._delRepos()
         self._delSacks()
+        yum.YumBase.close(self)
+        self.closeRpmDB()
 
         if not os.path.exists("/etc/fedora-release") and not os.path.exists("/etc/meego-release"):
             for i in range(3, os.sysconf("SC_OPEN_MAX")):
index f32b6a6..bcaccf0 100644 (file)
@@ -86,10 +86,10 @@ class Zypp(BackendPlugin):
         pass
 
     def close(self):
-        self.closeRpmDB()
         if self.ts:
             self.ts.closeDB()
             self.ts = None
+        self.closeRpmDB()
         if not os.path.exists("/etc/fedora-release") and not os.path.exists("/etc/meego-release"):
             for i in range(3, os.sysconf("SC_OPEN_MAX")):
                 try: