summaryrefslogtreecommitdiff
path: root/source3/locking/share_mode_lock.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-05-18 09:10:02 +0200
committerVolker Lendecke <vl@samba.org>2012-05-18 13:12:14 +0200
commitf5ca3f11e47e48d195616f813b5b2c9e8255c6cd (patch)
tree85456771e595ecdb101a1b521a188baff231ed26 /source3/locking/share_mode_lock.c
parent45082a88c7aaaa928ca36003ade071aafe4de54d (diff)
downloadsamba-f5ca3f11e47e48d195616f813b5b2c9e8255c6cd.tar.gz
samba-f5ca3f11e47e48d195616f813b5b2c9e8255c6cd.tar.bz2
samba-f5ca3f11e47e48d195616f813b5b2c9e8255c6cd.zip
s3: Revert the serverid changes, they need more work
Autobuild-User: Volker Lendecke <vl@samba.org> Autobuild-Date: Fri May 18 13:12:14 CEST 2012 on sn-devel-104
Diffstat (limited to 'source3/locking/share_mode_lock.c')
-rw-r--r--source3/locking/share_mode_lock.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 1fea748e72..f28332c226 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -118,6 +118,9 @@ static struct share_mode_data *parse_share_modes(TALLOC_CTX *mem_ctx,
const TDB_DATA dbuf)
{
struct share_mode_data *d;
+ int i;
+ struct server_id *pids;
+ bool *pid_exists;
enum ndr_err_code ndr_err;
DATA_BLOB blob;
@@ -145,6 +148,45 @@ static struct share_mode_data *parse_share_modes(TALLOC_CTX *mem_ctx,
NDR_PRINT_DEBUG(share_mode_data, d);
}
+ /*
+ * Ensure that each entry has a real process attached.
+ */
+
+ pids = talloc_array(talloc_tos(), struct server_id,
+ d->num_share_modes);
+ if (pids == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ goto fail;
+ }
+ pid_exists = talloc_array(talloc_tos(), bool, d->num_share_modes);
+ if (pid_exists == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ goto fail;
+ }
+
+ for (i=0; i<d->num_share_modes; i++) {
+ pids[i] = d->share_modes[i].pid;
+ }
+ if (!serverids_exist(pids, d->num_share_modes, pid_exists)) {
+ DEBUG(0, ("serverid_exists failed\n"));
+ goto fail;
+ }
+
+ i = 0;
+ while (i < d->num_share_modes) {
+ struct share_mode_entry *e = &d->share_modes[i];
+ if (!pid_exists[i]) {
+ DEBUG(10, ("wipe non-existent pid %s\n",
+ procid_str_static(&e->pid)));
+ *e = d->share_modes[d->num_share_modes-1];
+ d->num_share_modes -= 1;
+ d->modified = True;
+ continue;
+ }
+ i += 1;
+ }
+ TALLOC_FREE(pid_exists);
+ TALLOC_FREE(pids);
return d;
fail:
TALLOC_FREE(d);