summaryrefslogtreecommitdiffstats
path: root/source/locking/brlock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-04-04 20:38:12 +0000
committerJeremy Allison <jra@samba.org>2003-04-04 20:38:12 +0000
commit6999eef51c3e597b3b2cd9cc26138acdfbb6a23a (patch)
tree4f7909d10b35d1733753805fd1147212a90cb25b /source/locking/brlock.c
parentd0b2c5d7ba5531fc695a23bba87a1551cc39e2ee (diff)
downloadsamba-6999eef51c3e597b3b2cd9cc26138acdfbb6a23a.tar.gz
samba-6999eef51c3e597b3b2cd9cc26138acdfbb6a23a.tar.xz
samba-6999eef51c3e597b3b2cd9cc26138acdfbb6a23a.zip
Fix for very subtle POSIX lock interaction race condition found by
Herb. We need to unlock POSIX locks before notifying pending lock processes. Jeremy.
Diffstat (limited to 'source/locking/brlock.c')
-rw-r--r--source/locking/brlock.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/locking/brlock.c b/source/locking/brlock.c
index 4cd885f1a65..20d76c9c792 100644
--- a/source/locking/brlock.c
+++ b/source/locking/brlock.c
@@ -414,7 +414,9 @@ static BOOL brl_pending_overlap(struct lock_struct *lock, struct lock_struct *pe
BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
uint16 smbpid, pid_t pid, uint16 tid,
br_off start, br_off size,
- BOOL remove_pending_locks_only)
+ BOOL remove_pending_locks_only,
+ void (*pre_unlock_fn)(void *),
+ void *pre_unlock_data)
{
TDB_DATA kbuf, dbuf;
int count, i, j;
@@ -450,6 +452,10 @@ BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
lock->fnum == fnum &&
lock->start == start &&
lock->size == size) {
+
+ if (pre_unlock_fn)
+ (*pre_unlock_fn)(pre_unlock_data);
+
/* found it - delete it */
if (count == 1) {
tdb_delete(tdb, kbuf);
@@ -483,6 +489,11 @@ BOOL brl_unlock(SMB_DEV_T dev, SMB_INO_T ino, int fnum,
continue;
if (lock->lock_type != PENDING_LOCK) {
+
+ /* Do any POSIX unlocks needed. */
+ if (pre_unlock_fn)
+ (*pre_unlock_fn)(pre_unlock_data);
+
/* Send unlock messages to any pending waiters that overlap. */
for (j=0; j<count; j++) {
struct lock_struct *pend_lock = &locks[j];