summaryrefslogtreecommitdiff
path: root/source3/locking/locking.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-05-07 12:57:07 +0200
committerJeremy Allison <jra@samba.org>2012-05-25 09:19:37 -0700
commit5842d4e025e4c042829a585fe6c58b71b219386f (patch)
treec8979774e2f4455d65fb59e517ba983135d049e1 /source3/locking/locking.c
parent035342c11719d1daa647c0b2ae7cec27a969f83a (diff)
downloadsamba-5842d4e025e4c042829a585fe6c58b71b219386f.tar.gz
samba-5842d4e025e4c042829a585fe6c58b71b219386f.tar.bz2
samba-5842d4e025e4c042829a585fe6c58b71b219386f.zip
s3: Add "share_mode_stale_pid"
This is a helper routine that prunes a dead share mode entry on demand. This prepares for removing the serverids_exist call in parse_share_modes. Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/locking/locking.c')
-rw-r--r--source3/locking/locking.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index b9afd2392c..df21104028 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -625,6 +625,38 @@ bool is_deferred_open_entry(const struct share_mode_entry *e)
return (e->op_type == DEFERRED_OPEN_ENTRY);
}
+/*
+ * In case d->share_modes[i] conflicts with something or otherwise is
+ * being used, we need to make sure the corresponding process still
+ * exists. This routine checks it and potentially removes the entry
+ * from d->share_modes. Modifies d->num_share_modes, watch out in
+ * routines iterating over that array.
+ */
+bool share_mode_stale_pid(struct share_mode_data *d, unsigned i)
+{
+ struct share_mode_entry *e;
+
+ if (i > d->num_share_modes) {
+ DEBUG(1, ("Asking for index %u, only %u around\n",
+ i, (unsigned)d->num_share_modes));
+ return false;
+ }
+ e = &d->share_modes[i];
+ if (serverid_exists(&e->pid)) {
+ DEBUG(10, ("PID %s (index %u out of %u) still exists\n",
+ procid_str_static(&e->pid), i,
+ (unsigned)d->num_share_modes));
+ return false;
+ }
+ DEBUG(10, ("PID %s (index %u out of %u) does not exist anymore\n",
+ procid_str_static(&e->pid), i,
+ (unsigned)d->num_share_modes));
+ *e = d->share_modes[d->num_share_modes-1];
+ d->num_share_modes -= 1;
+ d->modified = true;
+ return true;
+}
+
/*******************************************************************
Fill a share mode entry.
********************************************************************/