Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/
Date: Sat, 07 May 2011 17:26:04
Message-Id: 48e1b835df5fefe49e2227e37c007d87fade1c55.zmedico@gentoo
1 commit: 48e1b835df5fefe49e2227e37c007d87fade1c55
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 7 17:25:20 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat May 7 17:25:20 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=48e1b835
7
8 PreserveLibsRegistry: add lock/unlock assertions
9
10 Also, add comments to store() about unobvious interaction with
11 locking due to atomic replacement of the inode.
12
13 ---
14 .../util/_dyn_libs/PreservedLibsRegistry.py | 13 ++++++++++++-
15 1 files changed, 12 insertions(+), 1 deletions(-)
16
17 diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
18 index f3cbb33..3fb8120 100644
19 --- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
20 +++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py
21 @@ -36,11 +36,16 @@ class PreservedLibsRegistry(object):
22
23 def lock(self):
24 """Grab an exclusive lock on the preserved libs registry."""
25 + if self._lock is not None:
26 + raise AssertionError("already locked")
27 self._lock = lockfile(self._filename)
28
29 def unlock(self):
30 """Release our exclusive lock on the preserved libs registry."""
31 + if self._lock is None:
32 + raise AssertionError("not locked")
33 unlockfile(self._lock)
34 + self._lock = None
35
36 def load(self):
37 """ Reload the registry data from file """
38 @@ -65,7 +70,13 @@ class PreservedLibsRegistry(object):
39 self.pruneNonExisting()
40
41 def store(self):
42 - """ Store the registry data to file """
43 + """
44 + Store the registry data to the file. The existing inode will be
45 + replaced atomically, so if that inode is currently being used
46 + for a lock then that lock will be rendered useless. Therefore,
47 + it is important not to call this method until the current lock
48 + is ready to be immediately released.
49 + """
50 if os.environ.get("SANDBOX_ON") == "1" or \
51 self._data == self._data_orig:
52 return