From 121b13cce3a302d586b8945fa311dc6afd55b3f3 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Wed, 1 Feb 2012 16:43:29 +0800 Subject: [PATCH] fix rpm db4 error(9): bad file descriptor 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 --- mic/imager/baseimager.py | 1 - plugins/backend/yumpkgmgr.py | 7 +++++-- plugins/backend/zypppkgmgr.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 6083cc8..12bc80f 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -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) diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 2971f71..3cd01f9 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -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")): diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index f32b6a6..bcaccf0 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -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: -- 2.7.4