Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 1/2] stagebase: simplify lock calls a bit
Date: Sun, 11 Oct 2015 01:54:50
Message-Id: 1444528479-3858-1-git-send-email-vapier@gentoo.org
1 We create self.snapcache_lock to hold the lock, then assign it to
2 self.snapshot_lock_object, and then operate on self.snapshot_lock_object.
3 There's no need for this indirection, so operate on self.snapcache_lock
4 directly instead.
5 ---
6 catalyst/base/stagebase.py | 10 ++++------
7 1 file changed, 4 insertions(+), 6 deletions(-)
8
9 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
10 index 88d71ba..3ce7dba 100644
11 --- a/catalyst/base/stagebase.py
12 +++ b/catalyst/base/stagebase.py
13 @@ -150,7 +150,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
14 self.set_source_subpath()
15
16 # Set paths
17 - self.snapshot_lock_object = None
18 self.set_snapshot_path()
19 self.set_root_path()
20 self.set_source_path()
21 @@ -822,7 +821,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
22 self.settings["snapshot_cache_path"]+\
23 " (This can take a long time)..."
24 cleanup_errmsg="Error removing existing snapshot cache directory."
25 - self.snapshot_lock_object=self.snapcache_lock
26
27 if self.settings["snapshot_path_hash"]==snapshot_cache_hash:
28 print "Valid snapshot cache, skipping unpack of portage tree..."
29 @@ -846,7 +844,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
30
31 if unpack:
32 if "snapcache" in self.settings["options"]:
33 - self.snapshot_lock_object.write_lock()
34 + self.snapcache_lock.write_lock()
35 if os.path.exists(target_portdir):
36 print cleanup_msg
37 cleanup_cmd = "rm -rf " + target_portdir
38 @@ -868,7 +866,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
39 data=self.settings["snapshot_path_hash"])
40
41 if "snapcache" in self.settings["options"]:
42 - self.snapshot_lock_object.unlock()
43 + self.snapcache_lock.unlock()
44
45 def config_profile_link(self):
46 if "autoresume" in self.settings["options"] \
47 @@ -946,7 +944,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
48 src=self.mountmap[x]
49 #print "bind(); src =", src
50 if "snapcache" in self.settings["options"] and x == "portdir":
51 - self.snapshot_lock_object.read_lock()
52 + self.snapcache_lock.read_lock()
53 if os.uname()[0] == "FreeBSD":
54 if src == "/dev":
55 _cmd = "mount -t devfs none " + target
56 @@ -998,7 +996,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
57 # It's possible the snapshot lock object isn't created yet.
58 # This is because mount safety check calls unbind before the
59 # target is fully initialized
60 - self.snapshot_lock_object.unlock()
61 + self.snapcache_lock.unlock()
62 except Exception:
63 pass
64 if ouch:
65 --
66 2.5.2

Replies