summaryrefslogtreecommitdiff
path: root/lib/spack/llnl/util/lock.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/llnl/util/lock.py')
-rw-r--r--lib/spack/llnl/util/lock.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py
index 86a45e2d7c..3a58093491 100644
--- a/lib/spack/llnl/util/lock.py
+++ b/lib/spack/llnl/util/lock.py
@@ -275,7 +275,12 @@ class Lock(object):
wait_time, nattempts = self._lock(fcntl.LOCK_EX, timeout=timeout)
self._acquired_debug('WRITE LOCK', wait_time, nattempts)
self._writes += 1
- return True
+
+ # return True only if we weren't nested in a read lock.
+ # TODO: we may need to return two values: whether we got
+ # the write lock, and whether this is acquiring a read OR
+ # write lock for the first time. Now it returns the latter.
+ return self._reads == 0
else:
self._writes += 1
return False