From: Ralph Boehme Date: Wed, 8 Jan 2025 14:43:04 +0000 (+0100) Subject: s3/brlock: don't increment current_lock_count if do_lock_fn() failed X-Git-Tag: samba-4.21.6~31 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=3ac1e43d46e8ac64b06e8ae0bbc8b52af8093be1;p=thirdparty%2Fsamba.git s3/brlock: don't increment current_lock_count if do_lock_fn() failed Also only assign psmblctx and pblocker_pid if the lock request failed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15767 Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher (cherry picked from commit 3a0c6e99de4377f44bc29766b6ceb79040caed9f) --- diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 41b54b14c6b..ea692711627 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -344,19 +344,21 @@ NTSTATUS do_lock(files_struct *fsp, nt_errstr(status)); return status; } - - if (psmblctx != NULL) { - *psmblctx = state.blocker_smblctx; - } - if (pblocker_pid != NULL) { - *pblocker_pid = state.blocker_pid; + if (!NT_STATUS_IS_OK(state.status)) { + DBG_DEBUG("do_lock_fn returned %s\n", + nt_errstr(state.status)); + if (psmblctx != NULL) { + *psmblctx = state.blocker_smblctx; + } + if (pblocker_pid != NULL) { + *pblocker_pid = state.blocker_pid; + } + return state.status; } - DBG_DEBUG("returning status=%s\n", nt_errstr(state.status)); - increment_current_lock_count(fsp, lock_flav); - return state.status; + return NT_STATUS_OK; } /****************************************************************************