]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: move lp_locking() check inside file_has_brlocks()
authorRalph Boehme <slow@samba.org>
Mon, 22 Sep 2025 15:28:23 +0000 (17:28 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 10 Oct 2025 15:59:35 +0000 (15:59 +0000)
Avoids doing the check at every caller.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/locking/brlock.c
source3/smbd/open.c

index e0f5c14c30221c34b2877b211cae1cc55613a461..39480a3275ba1f28d5b033d5542399d2886d891f 100644 (file)
@@ -2004,6 +2004,10 @@ bool file_has_brlocks(files_struct *fsp)
        struct byte_range_lock *br_lck = NULL;
        uint i, num_locks;
 
+       if (!lp_locking(fsp->conn->params)) {
+               return false;
+       }
+
        br_lck = brl_get_locks_readonly(fsp);
        if (br_lck == NULL) {
                return false;
index b0a080fabf2f196c6cc4b0b22b0d05affe5b832e..00bfa3e003ed8ecd7f0c76086de8605cbfab6a83 100644 (file)
@@ -2486,7 +2486,7 @@ grant:
                }
        }
 
-       if (lp_locking(fsp->conn->params) && file_has_brlocks(fsp)) {
+       if (file_has_brlocks(fsp)) {
                DBG_DEBUG("file %s has byte range locks\n",
                          fsp_str_dbg(fsp));
                granted &= ~(SMB2_LEASE_READ | SMB2_LEASE_HANDLE);