remove unused code and check chroot_lock before release
authorGui Chen <gui.chen@intel.com>
Wed, 14 Aug 2013 08:40:19 +0000 (04:40 -0400)
committerGui Chen <gui.chen@intel.com>
Wed, 14 Aug 2013 08:55:25 +0000 (04:55 -0400)
the open of chroot lock file is unneccessary, remove it;
if chroot_lock is None, release is invalid, check it.

Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/chroot.py

index 71cb8ab..342b5e8 100644 (file)
@@ -162,10 +162,6 @@ def setup_chrootenv(chrootdir, bindmounts = None):
     # update /etc/mtab
     setup_mtab(chrootdir)
 
-    # lock
-    chroot_lock = os.path.join(chrootdir, ".chroot.lock")
-    chroot_lockfd = open(chroot_lock, "w")
-
     return None
 
 ######################################################################
@@ -237,7 +233,9 @@ def cleanup_chrootenv(chrootdir, bindmounts=None, globalmounts=()):
     # clean up mounts
     cleanup_mounts(chrootdir)
     # release the lock
-    chroot_lock.release()
+    if chroot_lock:
+        chroot_lock.release()
+        chroot_lock = None
 
     return None