summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-07 20:05:21 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-11 22:17:11 -0700
commit32c4d1d7f05b8ab10a97a5ef965be14a8dd7e10b (patch)
treee96ba565aacaeabdb92d65c2ea0ccc0d1f522b3e /pym
parentdd1e101308407c1420373203fa75f7a814bd1d33 (diff)
downloadportage-32c4d1d7f05b8ab10a97a5ef965be14a8dd7e10b.tar.gz
portage-32c4d1d7f05b8ab10a97a5ef965be14a8dd7e10b.tar.bz2
portage-32c4d1d7f05b8ab10a97a5ef965be14a8dd7e10b.zip
vardbapi: acquire lock during counter_tick_core
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 1b13e1371..1302556fc 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -776,17 +776,25 @@ class vardbapi(dbapi):
to the global file. Returns new counter value.
@param myroot: ignored, self._eroot is used instead
+ @param mycpv: ignored
"""
myroot = None
- counter = self.get_counter_tick_core(mycpv=mycpv) - 1
- if incrementing:
- #increment counter
- counter += 1
- # use same permissions as config._init_dirs()
- ensure_dirs(os.path.dirname(self._counter_path),
- gid=portage_gid, mode=0o2750, mask=0o2)
- # update new global counter file
- write_atomic(self._counter_path, str(counter))
+ mycpv = None
+
+ self.lock()
+ try:
+ counter = self.get_counter_tick_core() - 1
+ if incrementing:
+ #increment counter
+ counter += 1
+ # use same permissions as config._init_dirs()
+ ensure_dirs(os.path.dirname(self._counter_path),
+ gid=portage_gid, mode=0o2750, mask=0o2)
+ # update new global counter file
+ write_atomic(self._counter_path, str(counter))
+ finally:
+ self.unlock()
+
return counter
def _dblink(self, cpv):