From 6a2d45df4712dd1830a715218b8ff910d0990a59 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 9 Dec 2013 14:24:37 +0100 Subject: [PATCH] [entropy.locks] set recursed to False only when the reference counter is 0 --- lib/entropy/locks.py | 6 +++--- lib/tests/locks.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/entropy/locks.py b/lib/entropy/locks.py index ef1bbfc4e..bce0fdee1 100644 --- a/lib/entropy/locks.py +++ b/lib/entropy/locks.py @@ -187,9 +187,6 @@ class _GenericResourceLock(object): lock_path = self.path() with self._lock_mutex: - # allow the same thread to acquire the lock again. - self._TLS.recursed = False - mapped = self._file_lock_setup(lock_path) if mapped['count'] == 0: @@ -210,6 +207,9 @@ class _GenericResourceLock(object): ref_obj.close() mapped['ref'] = None + # allow the same thread to acquire the lock again. + self._TLS.recursed = False + def _file_lock_create(self, lock_path, blocking=False, shared=False): """ Create and allocate the lock file pointed by lock_data structure. diff --git a/lib/tests/locks.py b/lib/tests/locks.py index c7ca61bd6..5e3ade998 100644 --- a/lib/tests/locks.py +++ b/lib/tests/locks.py @@ -97,7 +97,7 @@ class EntropyLocksTest(unittest.TestCase): erl.release() - self.assertEquals(False, erl.try_acquire_exclusive()) + self.assertRaises(RuntimeError, erl.try_acquire_exclusive) erl.release()