From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QIlGW-0000Ri-2I for garchives@archives.gentoo.org; Sat, 07 May 2011 17:26:04 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B9E641C047; Sat, 7 May 2011 17:25:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 849561C047 for ; Sat, 7 May 2011 17:25:41 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D71901B4082 for ; Sat, 7 May 2011 17:25:40 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 3643E80504 for ; Sat, 7 May 2011 17:25:40 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <48e1b835df5fefe49e2227e37c007d87fade1c55.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/util/_dyn_libs/PreservedLibsRegistry.py X-VCS-Directories: pym/portage/util/_dyn_libs/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 48e1b835df5fefe49e2227e37c007d87fade1c55 Date: Sat, 7 May 2011 17:25:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 5a78d81ef828a1b47ecfc93f62c5b0d9 commit: 48e1b835df5fefe49e2227e37c007d87fade1c55 Author: Zac Medico gentoo org> AuthorDate: Sat May 7 17:25:20 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat May 7 17:25:20 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D48e1b835 PreserveLibsRegistry: add lock/unlock assertions Also, add comments to store() about unobvious interaction with locking due to atomic replacement of the inode. --- .../util/_dyn_libs/PreservedLibsRegistry.py | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py b/pym/po= rtage/util/_dyn_libs/PreservedLibsRegistry.py index f3cbb33..3fb8120 100644 --- a/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py +++ b/pym/portage/util/_dyn_libs/PreservedLibsRegistry.py @@ -36,11 +36,16 @@ class PreservedLibsRegistry(object): =20 def lock(self): """Grab an exclusive lock on the preserved libs registry.""" + if self._lock is not None: + raise AssertionError("already locked") self._lock =3D lockfile(self._filename) =20 def unlock(self): """Release our exclusive lock on the preserved libs registry.""" + if self._lock is None: + raise AssertionError("not locked") unlockfile(self._lock) + self._lock =3D None =20 def load(self): """ Reload the registry data from file """ @@ -65,7 +70,13 @@ class PreservedLibsRegistry(object): self.pruneNonExisting() =20 def store(self): - """ Store the registry data to file """ + """ + Store the registry data to the file. The existing inode will be + replaced atomically, so if that inode is currently being used + for a lock then that lock will be rendered useless. Therefore, + it is important not to call this method until the current lock + is ready to be immediately released. + """ if os.environ.get("SANDBOX_ON") =3D=3D "1" or \ self._data =3D=3D self._data_orig: return