mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
r16973: Fix subtle logic error in lock ref counting found by
cifsfs client code. Jeremy. (This used to be commit 53094435d89088124041d57078c21a12e761e2bf)
This commit is contained in:
parent
4ef1f8e425
commit
297df32751
@ -1229,7 +1229,7 @@ void brl_close_fnum(struct byte_range_lock *br_lck)
|
||||
struct process_id pid = procid_self();
|
||||
BOOL unlock_individually = False;
|
||||
|
||||
if(lp_posix_locking(fsp->conn->cnum) && !lp_posix_cifsu_locktype()) {
|
||||
if(lp_posix_locking(fsp->conn->cnum)) {
|
||||
|
||||
/* Check if there are any Windows locks associated with this dev/ino
|
||||
pair that are not this fnum. If so we need to call unlock on each
|
||||
@ -1280,9 +1280,6 @@ void brl_close_fnum(struct byte_range_lock *br_lck)
|
||||
|
||||
/* We can bulk delete - any POSIX locks will be removed when the fd closes. */
|
||||
|
||||
/* Zero any lock reference count on this dev/ino pair. */
|
||||
zero_windows_lock_ref_count(fsp);
|
||||
|
||||
/* Remove any existing locks for this fnum (or any fnum if they're POSIX). */
|
||||
|
||||
for (i=0; i < br_lck->num_locks; i++) {
|
||||
@ -1336,6 +1333,9 @@ void brl_close_fnum(struct byte_range_lock *br_lck)
|
||||
dcount++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reduce the lock reference count on this dev/ino pair. */
|
||||
reduce_windows_lock_ref_count(fsp, dcount);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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));
|
||||
if (lock_ref_count < 0) {
|
||||
smb_panic("zero_windows_lock_ref_count: lock_count logic error.\n");
|
||||
}
|
||||
lock_ref_count -= dcount;
|
||||
|
||||
lock_ref_count = 0;
|
||||
if (lock_ref_count < 0) {
|
||||
smb_panic("reduce_windows_lock_ref_count: lock_count logic error.\n");
|
||||
}
|
||||
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 ));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user