From: Volker Lendecke Date: Mon, 30 Jul 2018 11:03:17 +0000 (+0200) Subject: smbd: Simplify share_mode_stale_pid X-Git-Tag: tdb-1.3.17~1683 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a76a317793d6ae8fa1ce05f4faacbd0978fd5cb;p=thirdparty%2Fsamba.git 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/locking/locking.c b/source3/locking/locking.c index b2681208cb8..e9bec6d763e 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -769,24 +769,20 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx) e->stale = true; if (d->num_delete_tokens != 0) { - uint32_t i, num_stale; - - /* - * We cannot have any delete tokens - * if there are no valid share modes. - */ - - num_stale = 0; + uint32_t i; for (i=0; inum_share_modes; i++) { - if (d->share_modes[i].stale) { - num_stale += 1; + bool valid = !d->share_modes[i].stale; + 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); d->num_delete_tokens = 0;