smbd: early out in is_visible_fsp()
authorRalph Boehme <slow@samba.org>
Wed, 3 Nov 2021 13:40:01 +0000 (14:40 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 3 Nov 2021 17:33:00 +0000 (17:33 +0000)
This is used in a hot codepath (directory enumeration) so we should avoiding the
string comparisions by adding an early exit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Nov  3 17:33:00 UTC 2021 on sn-devel-184

source3/smbd/dir.c

index 4d61bb0d56d54caebc0373fac868c5aa63e2224b..856a3625a75bbb86779ae24b257a93799dec14f0 100644 (file)
@@ -1356,6 +1356,14 @@ bool is_visible_fsp(struct files_struct *fsp)
        hide_special = lp_hide_special_files(SNUM(fsp->conn));
        hide_new_files_timeout = lp_hide_new_files_timeout(SNUM(fsp->conn));
 
+       if (!hide_unreadable &&
+           !hide_unwriteable &&
+           !hide_special &&
+           (hide_new_files_timeout == 0))
+       {
+               return true;
+       }
+
        if (fsp->base_fsp != NULL) {
                /* Only operate on non-stream files. */
                fsp = fsp->base_fsp;