summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-07-17 00:50:48 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:40 -0500
commit44b9493418558fca03b1888a693ba516b3711e17 (patch)
treeaf3d612427db2102eb0f07aec8deeb91283bb96d /source3/locking
parentb3d471d36740cc6afdf69cb1da438049fa1529a9 (diff)
downloadsamba-44b9493418558fca03b1888a693ba516b3711e17.tar.gz
samba-44b9493418558fca03b1888a693ba516b3711e17.tar.bz2
samba-44b9493418558fca03b1888a693ba516b3711e17.zip
r23908: Fix bug with interaction of optimization with
POSIX locking. We can't do lock counts with POSIX, so stop counting if we get a POSIX lock request. Jeremy. (This used to be commit a48e4a29e6774e5e72b9b361a17207b053474521)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index c7fb572b1d..8692001f44 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -40,6 +40,8 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_LOCKING
+#define NO_LOCKING_COUNT (-1)
+
/* the locking database handle */
static struct db_context *lock_db;
@@ -225,11 +227,19 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
blocking_lock,
plock_pid);
- /* blocking ie. pending, locks also count here,
- * as this is an efficiency counter to avoid checking
- * the lock db. on close. JRA. */
+ if (lock_flav == WINDOWS_LOCK &&
+ fsp->current_lock_count != NO_LOCKING_COUNT) {
+ /* blocking ie. pending, locks also count here,
+ * as this is an efficiency counter to avoid checking
+ * the lock db. on close. JRA. */
- fsp->current_lock_count++;
+ fsp->current_lock_count++;
+ } else {
+ /* Notice that this has had a POSIX lock request.
+ * We can't count locks after this so forget them.
+ */
+ fsp->current_lock_count = NO_LOCKING_COUNT;
+ }
return br_lck;
}
@@ -279,8 +289,11 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
return NT_STATUS_RANGE_NOT_LOCKED;
}
- SMB_ASSERT(fsp->current_lock_count > 0);
- fsp->current_lock_count--;
+ if (lock_flav == WINDOWS_LOCK &&
+ fsp->current_lock_count != NO_LOCKING_COUNT) {
+ SMB_ASSERT(fsp->current_lock_count > 0);
+ fsp->current_lock_count--;
+ }
return NT_STATUS_OK;
}
@@ -329,8 +342,11 @@ NTSTATUS do_lock_cancel(files_struct *fsp,
return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
}
- SMB_ASSERT(fsp->current_lock_count > 0);
- fsp->current_lock_count--;
+ if (lock_flav == WINDOWS_LOCK &&
+ fsp->current_lock_count != NO_LOCKING_COUNT) {
+ SMB_ASSERT(fsp->current_lock_count > 0);
+ fsp->current_lock_count--;
+ }
return NT_STATUS_OK;
}