1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

smbd: Do boolean short-circuiting

&= does bitwise AND, and does not do boolean short-circuiting if the
variable is already 0. As has_other_nonposix_opens() might have its
cost, this speeds up closing a handle.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2019-09-09 10:42:59 +02:00 committed by Jeremy Allison
parent 5427f73af5
commit 436be09cfc

View File

@ -350,9 +350,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
}
}
delete_file = is_delete_on_close_set(lck, fsp->name_hash);
delete_file &= !has_other_nonposix_opens(lck, fsp);
delete_file = is_delete_on_close_set(lck, fsp->name_hash) &&
!has_other_nonposix_opens(lck, fsp);
/*
* NT can set delete_on_close of the last open
@ -1156,10 +1155,9 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
}
}
delete_dir = get_delete_on_close_token(lck, fsp->name_hash,
&del_nt_token, &del_token);
delete_dir &= !has_other_nonposix_opens(lck, fsp);
delete_dir = get_delete_on_close_token(
lck, fsp->name_hash, &del_nt_token, &del_token) &&
!has_other_nonposix_opens(lck, fsp);
if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
delete_dir) {