From: Volker Lendecke Date: Tue, 13 Aug 2019 14:00:09 +0000 (+0200) Subject: smbd: Add share_entry_stale_pid() X-Git-Tag: talloc-2.3.1~814 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55e47ada9f85d5152b342d7d39226dc18bbaf162;p=thirdparty%2Fsamba.git smbd: Add share_entry_stale_pid() Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 72235113fbb..0cb6c6ff2f3 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -713,6 +713,30 @@ static void remove_share_mode_lease(struct share_mode_data *d, remove_lease_if_stale(d, &e->client_guid, &e->lease_key); } +bool share_entry_stale_pid(struct share_mode_entry *e) +{ + struct server_id_buf buf; + bool exists; + + if (e->stale) { + return true; + } + + exists = serverid_exists(&e->pid); + if (exists) { + DBG_DEBUG("PID %s still exists\n", + server_id_str_buf(e->pid, &buf)); + return false; + } + + DBG_DEBUG("PID %s does not exist anymore\n", + server_id_str_buf(e->pid, &buf)); + + e->stale = true; + + return true; +} + /* * In case d->share_modes[i] conflicts with something or otherwise is * being used, we need to make sure the corresponding process still diff --git a/source3/locking/proto.h b/source3/locking/proto.h index 7d2d28f4172..f60655eb590 100644 --- a/source3/locking/proto.h +++ b/source3/locking/proto.h @@ -169,6 +169,7 @@ void get_file_infos(struct file_id id, bool *delete_on_close, struct timespec *write_time); bool is_valid_share_mode_entry(const struct share_mode_entry *e); +bool share_entry_stale_pid(struct share_mode_entry *e); bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx); bool set_share_mode(struct share_mode_lock *lck, struct files_struct *fsp,