smbd: Add share_entry_stale_pid()
authorVolker Lendecke <vl@samba.org>
Tue, 13 Aug 2019 14:00:09 +0000 (16:00 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 17 Sep 2019 22:49:36 +0000 (22:49 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/locking.c
source3/locking/proto.h

index 72235113fbb981737a57fa64928e730527f047f3..0cb6c6ff2f33e01e4811b23e86bfc78babce1768 100644 (file)
@@ -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
index 7d2d28f4172ec41bdbed2a96cccf3c6ee8733bd3..f60655eb590878918b98e62bb114ea207f4a4800 100644 (file)
@@ -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,