Rev 4527: Make fcntl locks exclusive in lp:///~jameinel/bzr/1.18-lock-warnings

John Arbash Meinel john at arbash-meinel.com
Fri Jul 10 22:58:44 BST 2009


At lp:///~jameinel/bzr/1.18-lock-warnings

------------------------------------------------------------
revno: 4527
revision-id: john at arbash-meinel.com-20090710214924-9skgfm3b3ejakh6p
parent: john at arbash-meinel.com-20090710200724-hq5ls63lxocfaiu0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.18-lock-warnings
timestamp: Fri 2009-07-10 16:49:24 -0500
message:
  Make fcntl locks exclusive
-------------- next part --------------
=== modified file 'bzrlib/lock.py'
--- a/bzrlib/lock.py	2009-07-10 17:50:54 +0000
+++ b/bzrlib/lock.py	2009-07-10 21:49:24 +0000
@@ -168,7 +168,8 @@
             super(_fcntl_WriteLock, self).__init__()
             # Check we can grab a lock before we actually open the file.
             self.filename = osutils.realpath(filename)
-            if self.filename in _fcntl_WriteLock._open_locks:
+            if (self.filename in _fcntl_WriteLock._open_locks
+                or self.filename in _fcntl_ReadLock._open_locks):
                 self._clear_f()
                 raise errors.LockContention(self.filename)
 
@@ -201,6 +202,8 @@
         def __init__(self, filename):
             super(_fcntl_ReadLock, self).__init__()
             self.filename = osutils.realpath(filename)
+            if self.filename in _fcntl_WriteLock._open_locks:
+                raise errors.LockContention(self.filename)
             _fcntl_ReadLock._open_locks.setdefault(self.filename, 0)
             _fcntl_ReadLock._open_locks[self.filename] += 1
             self._open(filename, 'rb')



More information about the bazaar-commits mailing list