diff options
author | Jeremy Allison <jra@samba.org> | 2001-06-30 01:59:48 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-06-30 01:59:48 +0000 |
commit | d1f38ac53107d818b88cae9ee4d4442381dc4702 (patch) | |
tree | 3eeedd75a07466ad4055b5bf6ce1cbd7ea544b15 /source3/locking/brlock.c | |
parent | 51b83860a17cc04d7a7cab345b24af88e14f805e (diff) | |
download | samba-d1f38ac53107d818b88cae9ee4d4442381dc4702.tar.gz samba-d1f38ac53107d818b88cae9ee4d4442381dc4702.tar.xz samba-d1f38ac53107d818b88cae9ee4d4442381dc4702.zip |
Fixed the first locking error (test #8 found by locktest code from
Clarion locktest.
Jeremy.
(This used to be commit 5c42845b5bb6fafd0ebf93fbdd23d9bf861da865)
Diffstat (limited to 'source3/locking/brlock.c')
-rw-r--r-- | source3/locking/brlock.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index 8f733278308..7f3ec6757e3 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -341,13 +341,33 @@ smbpid = %u, pid = %u, tid = %u\n", } /**************************************************************************** + Check to see if this lock conflicts, but ignore our own locks on the + same fnum only. +****************************************************************************/ + +static BOOL brl_conflict_other(struct lock_struct *lck1, struct lock_struct *lck2) +{ + if (lck1->lock_type == READ_LOCK && lck2->lock_type == READ_LOCK) + return False; + + if (brl_same_context(&lck1->context, &lck2->context) && + lck1->fnum == lck2->fnum) + return False; + + if (lck1->start >= (lck2->start + lck2->size) || + lck2->start >= (lck1->start + lck1->size)) return False; + + return True; +} + +/**************************************************************************** Test if we could add a lock if we wanted to. ****************************************************************************/ BOOL brl_locktest(SMB_DEV_T dev, SMB_INO_T ino, int fnum, uint16 smbpid, pid_t pid, uint16 tid, br_off start, br_off size, - enum brl_type lock_type) + enum brl_type lock_type, int check_self) { TDB_DATA kbuf, dbuf; int count, i; @@ -373,8 +393,15 @@ BOOL brl_locktest(SMB_DEV_T dev, SMB_INO_T ino, int fnum, locks = (struct lock_struct *)dbuf.dptr; count = dbuf.dsize / sizeof(*locks); for (i=0; i<count; i++) { - if (brl_conflict(&locks[i], &lock)) { - goto fail; + if (check_self) { + if (brl_conflict(&locks[i], &lock)) + goto fail; + } else { + /* + * Our own locks don't conflict. + */ + if (brl_conflict_other(&locks[i], &lock)) + goto fail; } } } |