From: Volker Lendecke Date: Fri, 16 Aug 2019 09:11:36 +0000 (+0200) Subject: smbd: Use share_mode_forall_entries() in has_delete_on_close() X-Git-Tag: talloc-2.3.1~808 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b1fd018a2c47106102deb74bbd72fdf0c9faf02;p=thirdparty%2Fsamba.git smbd: Use share_mode_forall_entries() in has_delete_on_close() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index b411aaeb7f2..34e769176e6 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1615,24 +1615,36 @@ bool is_stat_open(uint32_t access_mask) ((access_mask & ~stat_open_bits) == 0)); } +struct has_delete_on_close_state { + bool ret; +}; + +static bool has_delete_on_close_fn( + struct share_mode_entry *e, + bool *modified, + void *private_data) +{ + struct has_delete_on_close_state *state = private_data; + state->ret = !share_entry_stale_pid(e); + return state->ret; +} + static bool has_delete_on_close(struct share_mode_lock *lck, uint32_t name_hash) { - struct share_mode_data *d = lck->data; - uint32_t i; + struct has_delete_on_close_state state = { .ret = false }; + bool ok; - if (d->num_share_modes == 0) { - return false; - } if (!is_delete_on_close_set(lck, name_hash)) { return false; } - for (i=0; inum_share_modes; i++) { - if (!share_mode_stale_pid(d, i)) { - return true; - } + + ok= share_mode_forall_entries(lck, has_delete_on_close_fn, &state); + if (!ok) { + DBG_DEBUG("share_mode_forall_entries failed\n"); + return false; } - return false; + return state.ret; } /****************************************************************************