From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 4432713888F for ; Sun, 11 Oct 2015 01:54:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A4D96E07F5; Sun, 11 Oct 2015 01:54:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 42AD6E07F5 for ; Sun, 11 Oct 2015 01:54:44 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id D058634067D for ; Sun, 11 Oct 2015 01:54:40 +0000 (UTC) From: Mike Frysinger To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH 1/2] stagebase: simplify lock calls a bit Date: Sat, 10 Oct 2015 21:54:38 -0400 Message-Id: <1444528479-3858-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 7c208c0d-0bf0-4427-9621-8a61c944c486 X-Archives-Hash: 7fa219ac8418fbe1de1de14947eb20ed We create self.snapcache_lock to hold the lock, then assign it to self.snapshot_lock_object, and then operate on self.snapshot_lock_object. There's no need for this indirection, so operate on self.snapcache_lock directly instead. --- catalyst/base/stagebase.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 88d71ba..3ce7dba 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -150,7 +150,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.set_source_subpath() # Set paths - self.snapshot_lock_object = None self.set_snapshot_path() self.set_root_path() self.set_source_path() @@ -822,7 +821,6 @@ class StageBase(TargetBase, ClearBase, GenBase): self.settings["snapshot_cache_path"]+\ " (This can take a long time)..." cleanup_errmsg="Error removing existing snapshot cache directory." - self.snapshot_lock_object=self.snapcache_lock if self.settings["snapshot_path_hash"]==snapshot_cache_hash: print "Valid snapshot cache, skipping unpack of portage tree..." @@ -846,7 +844,7 @@ class StageBase(TargetBase, ClearBase, GenBase): if unpack: if "snapcache" in self.settings["options"]: - self.snapshot_lock_object.write_lock() + self.snapcache_lock.write_lock() if os.path.exists(target_portdir): print cleanup_msg cleanup_cmd = "rm -rf " + target_portdir @@ -868,7 +866,7 @@ class StageBase(TargetBase, ClearBase, GenBase): data=self.settings["snapshot_path_hash"]) if "snapcache" in self.settings["options"]: - self.snapshot_lock_object.unlock() + self.snapcache_lock.unlock() def config_profile_link(self): if "autoresume" in self.settings["options"] \ @@ -946,7 +944,7 @@ class StageBase(TargetBase, ClearBase, GenBase): src=self.mountmap[x] #print "bind(); src =", src if "snapcache" in self.settings["options"] and x == "portdir": - self.snapshot_lock_object.read_lock() + self.snapcache_lock.read_lock() if os.uname()[0] == "FreeBSD": if src == "/dev": _cmd = "mount -t devfs none " + target @@ -998,7 +996,7 @@ class StageBase(TargetBase, ClearBase, GenBase): # It's possible the snapshot lock object isn't created yet. # This is because mount safety check calls unbind before the # target is fully initialized - self.snapshot_lock_object.unlock() + self.snapcache_lock.unlock() except Exception: pass if ouch: -- 2.5.2