[entropy.locks] set recursed to False only when the reference counter is 0

This commit is contained in:
Fabio Erculiani
2013-12-09 14:24:37 +01:00
parent d080db0d3b
commit 6a2d45df47
2 changed files with 4 additions and 4 deletions

View File

@@ -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.

View File

@@ -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()