public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
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	[thread overview]
Message-ID: <1444528479-3858-1-git-send-email-vapier@gentoo.org> (raw)

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



             reply	other threads:[~2015-10-11  1:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-11  1:54 Mike Frysinger [this message]
2015-10-11  1:54 ` [gentoo-catalyst] [PATCH 2/2] lock: gut & replace with snakeoil Mike Frysinger
2015-10-11 14:14 ` [gentoo-catalyst] [PATCH 1/2] stagebase: simplify lock calls a bit Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444528479-3858-1-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox