From 297df32751fbc64a053700241dae2ac9c0fc4968 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Jul 2006 06:56:43 +0000 Subject: r16973: Fix subtle logic error in lock ref counting found by cifsfs client code. Jeremy. (This used to be commit 53094435d89088124041d57078c21a12e761e2bf) --- source3/locking/posix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/locking/posix.c') diff --git a/source3/locking/posix.c b/source3/locking/posix.c index 59b62170e8..10845f9575 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -492,10 +492,10 @@ static void decrement_windows_lock_ref_count(files_struct *fsp) } /**************************************************************************** - Ensure the lock ref count is zero. + Bulk delete - subtract as many locks as we've just deleted. ****************************************************************************/ -void zero_windows_lock_ref_count(files_struct *fsp) +void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount) { TDB_DATA kbuf = locking_ref_count_key_fsp(fsp); TDB_DATA dbuf; @@ -507,19 +507,19 @@ void zero_windows_lock_ref_count(files_struct *fsp) } memcpy(&lock_ref_count, dbuf.dptr, sizeof(int)); + lock_ref_count -= dcount; + if (lock_ref_count < 0) { - smb_panic("zero_windows_lock_ref_count: lock_count logic error.\n"); + smb_panic("reduce_windows_lock_ref_count: lock_count logic error.\n"); } - - lock_ref_count = 0; memcpy(dbuf.dptr, &lock_ref_count, sizeof(int)); if (tdb_store(posix_pending_close_tdb, kbuf, dbuf, TDB_REPLACE) == -1) { - smb_panic("zero_windows_lock_ref_count: tdb_store_fail.\n"); + smb_panic("reduce_windows_lock_ref_count: tdb_store_fail.\n"); } SAFE_FREE(dbuf.dptr); - DEBUG(10,("zero_windows_lock_ref_count for file now %s = %d\n", + DEBUG(10,("reduce_windows_lock_ref_count for file now %s = %d\n", fsp->fsp_name, lock_ref_count )); } -- cgit