1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-27 14:04:05 +03:00

smbd: Simplify share_mode_stale_pid

This loop does not need to count valid share modes. A single valid one
is sufficient for keeping the delete token around

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2018-07-30 13:03:17 +02:00 committed by Andreas Schneider
parent 45a2e3eb53
commit 6a76a31779

View File

@ -769,24 +769,20 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx)
e->stale = true; e->stale = true;
if (d->num_delete_tokens != 0) { if (d->num_delete_tokens != 0) {
uint32_t i, num_stale; uint32_t i;
/*
* We cannot have any delete tokens
* if there are no valid share modes.
*/
num_stale = 0;
for (i=0; i<d->num_share_modes; i++) { for (i=0; i<d->num_share_modes; i++) {
if (d->share_modes[i].stale) { bool valid = !d->share_modes[i].stale;
num_stale += 1; if (valid) {
break;
} }
} }
if (num_stale == d->num_share_modes) { if (i == d->num_share_modes) {
/* /*
* No non-stale share mode found * No valid (non-stale) share mode found, all
* who might have set the delete token are
* gone.
*/ */
TALLOC_FREE(d->delete_tokens); TALLOC_FREE(d->delete_tokens);
d->num_delete_tokens = 0; d->num_delete_tokens = 0;