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