From bc5d73fa3db0569c55d48c2e738f12742579536c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 7 May 2011 20:05:21 -0700 Subject: vardbapi: acquire lock during counter_tick_core --- pym/portage/dbapi/vartree.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index bc9916e31..2708e4307 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -779,17 +779,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): -- cgit v1.2.3-1-g7c22