s3 BRL: Add more clarifying comments and add implied logic to make conditional more...
authorZack Kirsch <zack.kirsch@isilon.com>
Fri, 20 Feb 2009 23:22:15 +0000 (15:22 -0800)
committerTim Prouty <tprouty@samba.org>
Sat, 21 Feb 2009 00:42:50 +0000 (16:42 -0800)
source3/locking/brlock.c

index d12c4affc38f946358831d2f4ddfc17933959797..aa522ac7801ebc77f34c51f0760f9bfaa28be9ab 100644 (file)
@@ -74,6 +74,7 @@ bool brl_same_context(const struct lock_context *ctx1,
 static bool brl_overlap(const struct lock_struct *lck1,
                         const struct lock_struct *lck2)
 {
+       /* XXX Remove for Win7 compatibility. */
        /* this extra check is not redundent - it copes with locks
           that go beyond the end of 64 bit file space */
        if (lck1->size != 0 &&
@@ -105,8 +106,11 @@ static bool brl_conflict(const struct lock_struct *lck1,
                return False;
        }
 
-       if (brl_same_context(&lck1->context, &lck2->context) &&
-           lck2->lock_type == READ_LOCK && lck1->fnum == lck2->fnum) {
+       /* A READ lock can stack on top of a WRITE lock if they have the same
+        * context & fnum. */
+       if (lck1->lock_type == WRITE_LOCK && lck2->lock_type == READ_LOCK &&
+           brl_same_context(&lck1->context, &lck2->context) &&
+           lck1->fnum == lck2->fnum) {
                return False;
        }