]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server: Optionally skip counting byte range locks when enumerating files
authorRalph Wuerthner <ralph.wuerthner@de.ibm.com>
Tue, 8 May 2018 08:52:08 +0000 (10:52 +0200)
committerAnoop C S <anoopcs@samba.org>
Tue, 14 Apr 2026 08:57:30 +0000 (08:57 +0000)
Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Xavi Hernandez <xhernandez@redhat.com>
Reviewed-by: Shweta Sodani <ssodani@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/rpc_server/srvsvc/srv_srvsvc_nt.c

index bcc99e576f8716ce8ff9cbc9299fa2f1d4a9ed0a..0482dcc68edd4b1a804d3a5603d7c480bf682a9c 100644 (file)
@@ -184,16 +184,18 @@ static WERROR net_enum_files(TALLOC_CTX *ctx,
                .ctx = ctx, .username = username, .ctr3 = *ctr3,
        };
        uint32_t i;
+       bool count_file_locks =
+               lp_parm_bool(-1, "srvsvc", "file enum count locks", true);
 
        share_entry_forall_read(enum_file_fn, (void *)&f_enum_cnt );
 
        *ctr3 = f_enum_cnt.ctr3;
 
        /* need to count the number of locks on a file */
-
        for (i=0; i<(*ctr3)->count; i++) {
                struct files_struct *fsp = NULL;
                struct byte_range_lock *brl = NULL;
+               unsigned int num_locks = 0;
 
                fsp = talloc_zero(talloc_tos(), struct files_struct);
                if (fsp == NULL) {
@@ -201,13 +203,16 @@ static WERROR net_enum_files(TALLOC_CTX *ctx,
                }
                fsp->file_id = f_enum_cnt.fids[i];
 
-               brl = brl_get_locks_readonly(fsp);
-               if (brl == NULL) {
-                       continue;
+               if (count_file_locks) {
+                       brl = brl_get_locks_readonly(fsp);
+                       if (brl != NULL) {
+                               num_locks = brl_num_locks(brl);
+                               TALLOC_FREE(brl);
+                       }
                }
 
-               (*ctr3)->array[i].num_locks = brl_num_locks(brl);
-               TALLOC_FREE(brl);
+               (*ctr3)->array[i].num_locks = num_locks;
+
                TALLOC_FREE(fsp);
        }