[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Oct 1 00:54:04 UTC 2015


The branch, master has been updated
       via  22c5699 lib: Fix server_id_db_set_exclusive
       via  2c12b51 lib: Add "pid/unique" format for server_id_from_string
       via  a4f6450 lib: Fix server_id_from_string
       via  8044e2d lib: Add server_id_str_buf_unique
       via  620b746 lib: Remove ctdb_serverids_exist
       via  103658d lib: Remove serverids_exist
       via  b542ce7 lib: Use messaging_dgm_get_unique in serverid_exists
       via  c793fb8 lib: Use serverid_exists in server_id_db_check_exclusive
       via  37f01c8 messages_dgm: Add messaging_dgm_get_unique
       via  beb7c6b net: Add "serverid exists"
       via  e119f95 net: Fix some tiny memleaks
       via  348dd41 s3:lib:interface: break an overly long line
       via  d8b2421 s4-scripting: fix minor indent issue for hresult generation.
       via  f5109df s4-scripting: fix wrong indent that caused gen_ntstatus.py to fail.
       via  dea49cc ldb: Fix CID 1034781 Unsigned compared against 0
      from  edd18f7 messages_dgm: Fix an incorrect cast

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 22c5699751d8a7b3eda33260c7ec9f0a8771d25b
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 20:24:10 2015 +0200

    lib: Fix server_id_db_set_exclusive
    
    For server_id_db_set_exclusive we need to store the unique id along
    with the vnn:pid combo. I had tested all this just with some
    smbtorture and net command tests, all of which have a unique id of
    zero. When trying to exclusively register "notify-daemon" when smbd
    is running, this fails because serverid_exists only tests with zero
    unique id. notifyd does have a non-zero unique id, so server_id_exists
    will think the existing notifyd is another non-samba process that
    happened to claim notifyd's pid.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Oct  1 02:53:58 CEST 2015 on sn-devel-104

commit 2c12b516a98778baf6a0aa06c70e94bded1b48ed
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 20:16:56 2015 +0200

    lib: Add "pid/unique" format for server_id_from_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a4f64500a5c3c89aae0c6eb15e994898d0ce38e7
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 20:08:48 2015 +0200

    lib: Fix server_id_from_string
    
    sscanf overwrites vars as numbers come in. So the first sscanf will
    overwrite "vnn", although it can't scan the whole thing. This leads
    to the string "1234" return .vnn=1234, pid=1234. Bad.
    
    While there, save the temp variables. The SCNu32/64 thingies look
    ugly, but it's actually c99.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8044e2dcc074ade554150ebc11b60d91db025f63
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 04:03:52 2015 +0200

    lib: Add server_id_str_buf_unique
    
    A representation including the unique id
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 620b7467adebb756e6658c6901232755a8c62d17
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 30 01:27:00 2015 +0200

    lib: Remove ctdb_serverids_exist
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 103658ddd0992d00f5a4b1411dcb808d035cb917
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 30 01:14:33 2015 +0200

    lib: Remove serverids_exist
    
    The only reason for this complex monster was an overload of ctdbd.
    When opening files, we unconditionally checked all share modes for
    validity. This meant thousands of serverid_exists calls per second
    for popular directories. This has long gone, now we only check for
    validity if a conflict happens.
    
    The only remaining caller is net serverid wipedbs, an administrative
    command. If that loads ctdbd, so be it.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b542ce7db394de3023b95288b0c40c4533c02cb1
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 30 01:11:08 2015 +0200

    lib: Use messaging_dgm_get_unique in serverid_exists
    
    This is a relevant change: I was experimenting with
    server_id_db_set_exclusive() in "net" and got failures all over the
    place. The main reason was that "net" by default does not do a
    serverid_register. With messaging_dgm we have the process' unique
    id available via the lockfile contents. Using open/read/close is a
    bit slower than local tdb access, but this version is safe for all
    processes which have done messaging_init()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c793fb8a66e6837b2d2bc1f2f2d3ec5bc1edee84
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 30 01:01:46 2015 +0200

    lib: Use serverid_exists in server_id_db_check_exclusive
    
    If there's another process around there will typically be at most
    one process. So there is no real need to run the plural version of
    serverid_exists.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 37f01c869de14e0f0e6d609e2b8f3448167c11db
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 30 00:31:17 2015 +0200

    messages_dgm: Add messaging_dgm_get_unique
    
    To be able to read, we need to open the lockfile O_RDWR instead of O_WRONLY
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit beb7c6b9411cb02d873b5ce1b4210dc2a775e93d
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 23:39:46 2015 +0200

    net: Add "serverid exists"
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e119f95532710f0c8d65cfb3dca54145c942e12c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 29 20:42:58 2015 +0200

    net: Fix some tiny memleaks
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 348dd41871527768ac4b5386183930837e187976
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 22 01:27:48 2015 +0200

    s3:lib:interface: break an overly long line
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d8b2421767fbfdb84572702cb77309550d27dc27
Author: Günther Deschner <gd at samba.org>
Date:   Wed Sep 30 08:27:04 2015 +0200

    s4-scripting: fix minor indent issue for hresult generation.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f5109dfcdb47432bc85ec3058d4f0f2b4fd15700
Author: Günther Deschner <gd at samba.org>
Date:   Wed Sep 30 08:14:06 2015 +0200

    s4-scripting: fix wrong indent that caused gen_ntstatus.py to fail.
    
    Verified it now works again with:
    
    ./source4/scripting/bin/gen_ntstatus.py libcli/util/ntstatus.h MS-ERREF-2.3.1.NTSTATUS libcli/util/nterr.c
    
    MS-ERREF-2.3.1.NTSTATUS as the copied content from
    https://msdn.microsoft.com/en-us/library/cc704588.aspx.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dea49cc7c07bb1206cf8600eeb9fa699c1ca0d75
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 18 22:25:25 2015 +0200

    ldb: Fix CID 1034781 Unsigned compared against 0
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb/common/ldb_controls.c         |   6 +-
 lib/util/samba_util.h                 |   1 +
 lib/util/server_id.c                  | 110 ++++++++++++---
 lib/util/server_id_db.c               |  23 ++--
 source3/include/ctdbd_conn.h          |   4 -
 source3/include/serverid.h            |   5 -
 source3/lib/ctdb_dummy.c              |  13 +-
 source3/lib/ctdbd_conn.c              | 243 ----------------------------------
 source3/lib/interface.c               |   4 +-
 source3/lib/messages_dgm.c            |  62 ++++++++-
 source3/lib/messages_dgm.h            |   1 +
 source3/lib/server_id_db_util.c       |   9 +-
 source3/lib/serverid.c                | 231 +++-----------------------------
 source3/utils/net.c                   |   4 +-
 source3/utils/net_serverid.c          |  44 ++++++
 source4/scripting/bin/gen_hresult.py  |   2 +-
 source4/scripting/bin/gen_ntstatus.py |  30 +++--
 17 files changed, 262 insertions(+), 530 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c
index 097ae20..8747d53 100644
--- a/lib/ldb/common/ldb_controls.c
+++ b/lib/ldb/common/ldb_controls.c
@@ -492,7 +492,7 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
 		p = &(control_strings[sizeof(LDB_CONTROL_DIRSYNC_NAME)]);
 		ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie);
 
-		if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) {
+		if ((ret < 3) || (crit < 0) || (crit > 1) || (max_attrs < 0)) {
 			error_string = talloc_asprintf(mem_ctx, "invalid dirsync control syntax\n");
 			error_string = talloc_asprintf_append(error_string, " syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n");
 			error_string = talloc_asprintf_append(error_string, "   note: b = boolean, n = number, o = b64 binary blob");
@@ -598,7 +598,7 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
 
 		p = &(control_strings[sizeof(LDB_CONTROL_SD_FLAGS_NAME)]);
 		ret = sscanf(p, "%d:%u", &crit, &secinfo_flags);
-		if ((ret != 2) || (crit < 0) || (crit > 1) || (secinfo_flags < 0) || (secinfo_flags > 0xF)) {
+		if ((ret != 2) || (crit < 0) || (crit > 1) || (secinfo_flags > 0xF)) {
 			error_string = talloc_asprintf(mem_ctx, "invalid sd_flags control syntax\n");
 			error_string = talloc_asprintf_append(error_string, " syntax: crit(b):secinfo_flags(n)\n");
 			error_string = talloc_asprintf_append(error_string, "   note: b = boolean, n = number");
@@ -625,7 +625,7 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
 
 		p = &(control_strings[sizeof(LDB_CONTROL_SEARCH_OPTIONS_NAME)]);
 		ret = sscanf(p, "%d:%u", &crit, &search_options);
-		if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options < 0) || (search_options > 0xF)) {
+		if ((ret != 2) || (crit < 0) || (crit > 1) || (search_options > 0xF)) {
 			error_string = talloc_asprintf(mem_ctx, "invalid search_options control syntax\n");
 			error_string = talloc_asprintf_append(error_string, " syntax: crit(b):search_options(n)\n");
 			error_string = talloc_asprintf_append(error_string, "   note: b = boolean, n = number");
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 496923c..d2868d7 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -847,6 +847,7 @@ struct server_id;
 
 struct server_id_buf { char buf[48]; }; /* probably a bit too large ... */
 char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
+size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen);
 
 bool server_id_same_process(const struct server_id *p1,
 			    const struct server_id *p2);
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index 60b5235..83a262d 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -65,14 +65,36 @@ char *server_id_str_buf(struct server_id id, struct server_id_buf *dst)
 	return dst->buf;
 }
 
+size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen)
+{
+	struct server_id_buf idbuf;
+	char unique_buf[21];	/* 2^64 is 18446744073709551616, 20 chars */
+	size_t idlen, unique_len, needed;
+
+	server_id_str_buf(id, &idbuf);
+
+	idlen = strlen(idbuf.buf);
+	unique_len = snprintf(unique_buf, sizeof(unique_buf), "%"PRIu64,
+			      id.unique_id);
+	needed = idlen + unique_len + 2;
+
+	if (buflen >= needed) {
+		memcpy(buf, idbuf.buf, idlen);
+		buf[idlen] = '/';
+		memcpy(buf + idlen + 1, unique_buf, unique_len+1);
+	}
+
+	return needed;
+}
+
 struct server_id server_id_from_string(uint32_t local_vnn,
 				       const char *pid_string)
 {
+	struct server_id templ = {
+		.vnn = NONCLUSTER_VNN, .pid = UINT64_MAX
+	};
 	struct server_id result;
-	unsigned long long pid;
-	unsigned int vnn, task_id = 0;
-
-	ZERO_STRUCT(result);
+	int ret;
 
 	/*
 	 * We accept various forms with 1, 2 or 3 component forms
@@ -80,27 +102,73 @@ struct server_id server_id_from_string(uint32_t local_vnn,
 	 * we want backwards compatibility for scripts that may call
 	 * smbclient.
 	 */
-	if (sscanf(pid_string, "%u:%llu.%u", &vnn, &pid, &task_id) == 3) {
-		result.vnn = vnn;
-		result.pid = pid;
-		result.task_id = task_id;
-	} else if (sscanf(pid_string, "%u:%llu", &vnn, &pid) == 2) {
-		result.vnn = vnn;
-		result.pid = pid;
-	} else if (sscanf(pid_string, "%llu.%u", &pid, &task_id) == 2) {
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu32":%"SCNu64".%"SCNu32"/%"SCNu64,
+		     &result.vnn, &result.pid, &result.task_id,
+		     &result.unique_id);
+	if (ret == 4) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu32":%"SCNu64".%"SCNu32,
+		     &result.vnn, &result.pid, &result.task_id);
+	if (ret == 3) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu32":%"SCNu64"/%"SCNu64,
+		     &result.vnn, &result.pid, &result.unique_id);
+	if (ret == 3) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu32":%"SCNu64,
+		     &result.vnn, &result.pid);
+	if (ret == 2) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu64".%"SCNu32"/%"SCNu64,
+		     &result.pid, &result.task_id, &result.unique_id);
+	if (ret == 3) {
+		result.vnn = local_vnn;
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu64".%"SCNu32,
+		     &result.pid, &result.task_id);
+	if (ret == 2) {
 		result.vnn = local_vnn;
-		result.pid = pid;
-		result.task_id = task_id;
-	} else if (sscanf(pid_string, "%llu", &pid) == 1) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu64"/%"SCNu64,
+		     &result.pid, &result.unique_id);
+	if (ret == 2) {
 		result.vnn = local_vnn;
-		result.pid = pid;
-	} else if (strcmp(pid_string, "disconnected") ==0) {
+		return result;
+	}
+
+	result = templ;
+	ret = sscanf(pid_string, "%"SCNu64, &result.pid);
+	if (ret == 1) {
+		result.vnn = local_vnn;
+		return result;
+	}
+
+	if (strcmp(pid_string, "disconnected") == 0) {
 		server_id_set_disconnected(&result);
-	} else {
-		result.vnn = NONCLUSTER_VNN;
-		result.pid = UINT64_MAX;
+		return result;
 	}
-	return result;
+
+	return templ;
 }
 
 /**
diff --git a/lib/util/server_id_db.c b/lib/util/server_id_db.c
index 0874129..1e65ce2 100644
--- a/lib/util/server_id_db.c
+++ b/lib/util/server_id_db.c
@@ -93,8 +93,7 @@ static int server_id_db_destructor(struct server_id_db *db)
 int server_id_db_add(struct server_id_db *db, const char *name)
 {
 	struct tdb_context *tdb = db->tdb->tdb;
-	struct server_id_buf buf;
-	TDB_DATA key, data;
+	TDB_DATA key;
 	char *n;
 	int ret;
 
@@ -110,10 +109,17 @@ int server_id_db_add(struct server_id_db *db, const char *name)
 
 	key = string_term_tdb_data(name);
 
-	server_id_str_buf(db->pid, &buf);
-	data = string_term_tdb_data(buf.buf);
+	{
+		size_t idlen = server_id_str_buf_unique(db->pid, NULL, 0);
+		char idbuf[idlen];
+
+		server_id_str_buf_unique(db->pid, idbuf, idlen);
+
+		ret = tdb_append(
+			tdb, key,
+			(TDB_DATA) { .dptr = (uint8_t *)idbuf, .dsize = idlen });
+	}
 
-	ret = tdb_append(tdb, key, data);
 	if (ret != 0) {
 		enum TDB_ERROR err = tdb_error(tdb);
 		strv_delete(&db->names, strv_find(db->names, name));
@@ -127,14 +133,15 @@ int server_id_db_prune_name(struct server_id_db *db, const char *name,
 			    struct server_id server)
 {
 	struct tdb_context *tdb = db->tdb->tdb;
-	struct server_id_buf buf;
+	size_t idbuf_len = server_id_str_buf_unique(server, NULL, 0);
+	char idbuf[idbuf_len];
 	TDB_DATA key;
 	uint8_t *data;
 	char *ids, *id;
 	int ret;
 
 	key = string_term_tdb_data(name);
-	server_id_str_buf(server, &buf);
+	server_id_str_buf_unique(server, idbuf, idbuf_len);
 
 	ret = tdb_chainlock(tdb, key);
 	if (ret == -1) {
@@ -150,7 +157,7 @@ int server_id_db_prune_name(struct server_id_db *db, const char *name,
 
 	ids = (char *)data;
 
-	id = strv_find(ids, buf.buf);
+	id = strv_find(ids, idbuf);
 	if (id == NULL) {
 		tdb_chainunlock(tdb, key);
 		TALLOC_FREE(data);
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
index b60a0e5..9f7ec9f 100644
--- a/source3/include/ctdbd_conn.h
+++ b/source3/include/ctdbd_conn.h
@@ -47,10 +47,6 @@ bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn,
 bool ctdb_processes_exist(struct ctdbd_connection *conn,
 			  const struct server_id *pids, int num_pids,
 			  bool *results);
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn);
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, unsigned num_pids,
-			  bool *results);
 
 char *ctdbd_dbpath(struct ctdbd_connection *conn,
 		   TALLOC_CTX *mem_ctx, uint32_t db_id);
diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index d1d405a..24ebcbe 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -39,11 +39,6 @@ bool serverid_deregister(const struct server_id id);
 bool serverid_exists(const struct server_id *id);
 
 /*
- * Check existence of a list of server ids
- */
-bool serverids_exist(const struct server_id *ids, int num_ids, bool *results);
-
-/*
  * Walk the list of server_ids registered
  */
 bool serverid_traverse(int (*fn)(struct db_record *rec,
diff --git a/source3/lib/ctdb_dummy.c b/source3/lib/ctdb_dummy.c
index df05de7..2d1f6de 100644
--- a/source3/lib/ctdb_dummy.c
+++ b/source3/lib/ctdb_dummy.c
@@ -63,21 +63,14 @@ const char *lp_ctdbd_socket(void)
 	return "";
 }
 
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn)
-{
-	return false;
-}
-
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, unsigned num_pids,
+bool ctdb_processes_exist(struct ctdbd_connection *conn,
+			  const struct server_id *pids, int num_pids,
 			  bool *results)
 {
 	return false;
 }
 
-bool ctdb_processes_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, int num_pids,
-			  bool *results)
+bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
 {
 	return false;
 }
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index 1acce12..9aec517 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -856,249 +856,6 @@ fail:
 	return result;
 }
 
-struct ctdb_vnn_list {
-	uint32_t vnn;
-	uint32_t reqid;
-	unsigned num_srvids;
-	unsigned num_filled;
-	uint64_t *srvids;
-	unsigned *pid_indexes;
-};
-
-/*
- * Get a list of all vnns mentioned in a list of
- * server_ids. vnn_indexes tells where in the vnns array we have to
- * place the pids.
- */
-static bool ctdb_collect_vnns(TALLOC_CTX *mem_ctx,
-			      const struct server_id *pids, unsigned num_pids,
-			      struct ctdb_vnn_list **pvnns,
-			      unsigned *pnum_vnns)
-{
-	struct ctdb_vnn_list *vnns = NULL;
-	unsigned *vnn_indexes = NULL;
-	unsigned i, num_vnns = 0;
-
-	vnn_indexes = talloc_array(mem_ctx, unsigned, num_pids);
-	if (vnn_indexes == NULL) {
-		DEBUG(1, ("talloc_array failed\n"));
-		goto fail;
-	}
-
-	for (i=0; i<num_pids; i++) {
-		unsigned j;
-		uint32_t vnn = pids[i].vnn;
-
-		for (j=0; j<num_vnns; j++) {
-			if (vnn == vnns[j].vnn) {
-				break;
-			}
-		}
-		vnn_indexes[i] = j;
-
-		if (j < num_vnns) {
-			/*
-			 * Already in the array
-			 */
-			vnns[j].num_srvids += 1;
-			continue;
-		}
-		vnns = talloc_realloc(mem_ctx, vnns, struct ctdb_vnn_list,
-				      num_vnns+1);
-		if (vnns == NULL) {
-			DEBUG(1, ("talloc_realloc failed\n"));
-			goto fail;
-		}
-		vnns[num_vnns].vnn = vnn;
-		vnns[num_vnns].num_srvids = 1;
-		vnns[num_vnns].num_filled = 0;
-		num_vnns += 1;
-	}
-	for (i=0; i<num_vnns; i++) {
-		struct ctdb_vnn_list *vnn = &vnns[i];
-
-		vnn->srvids = talloc_array(vnns, uint64_t, vnn->num_srvids);
-		if (vnn->srvids == NULL) {
-			DEBUG(1, ("talloc_array failed\n"));
-			goto fail;
-		}
-		vnn->pid_indexes = talloc_array(vnns, unsigned,
-						vnn->num_srvids);
-		if (vnn->pid_indexes == NULL) {
-			DEBUG(1, ("talloc_array failed\n"));
-			goto fail;
-		}
-	}
-	for (i=0; i<num_pids; i++) {
-		struct ctdb_vnn_list *vnn = &vnns[vnn_indexes[i]];
-		vnn->srvids[vnn->num_filled] = pids[i].unique_id;
-		vnn->pid_indexes[vnn->num_filled] = i;
-		vnn->num_filled += 1;
-	}
-
-	TALLOC_FREE(vnn_indexes);
-	*pvnns = vnns;
-	*pnum_vnns = num_vnns;
-	return true;
-fail:
-	TALLOC_FREE(vnns);
-	TALLOC_FREE(vnn_indexes);
-	return false;
-}
-
-bool ctdb_serverids_exist_supported(struct ctdbd_connection *conn)
-{
-	return true;
-}
-
-bool ctdb_serverids_exist(struct ctdbd_connection *conn,
-			  const struct server_id *pids, unsigned num_pids,
-			  bool *results)
-{
-	unsigned i, num_received;
-	struct ctdb_vnn_list *vnns = NULL;
-	unsigned num_vnns;
-
-	if (!ctdb_collect_vnns(talloc_tos(), pids, num_pids,
-			       &vnns, &num_vnns)) {
-		DEBUG(1, ("ctdb_collect_vnns failed\n"));
-		goto fail;
-	}
-
-	for (i=0; i<num_vnns; i++) {
-		struct ctdb_vnn_list *vnn = &vnns[i];
-		struct ctdb_req_control req;
-		struct iovec iov[2];
-		ssize_t nwritten;
-
-		vnn->reqid = ctdbd_next_reqid(conn);
-
-		ZERO_STRUCT(req);
-
-		DEBUG(10, ("Requesting VNN %d, reqid=%d, num_srvids=%u\n",
-			   (int)vnn->vnn, (int)vnn->reqid, vnn->num_srvids));
-
-		req.hdr.length = offsetof(struct ctdb_req_control, data);
-		req.hdr.ctdb_magic   = CTDB_MAGIC;
-		req.hdr.ctdb_version = CTDB_PROTOCOL;
-		req.hdr.operation    = CTDB_REQ_CONTROL;
-		req.hdr.reqid        = vnn->reqid;
-		req.hdr.destnode     = vnn->vnn;
-		req.opcode           = CTDB_CONTROL_CHECK_SRVIDS;
-		req.srvid            = 0;
-		req.datalen          = sizeof(uint64_t) * vnn->num_srvids;
-		req.hdr.length	    += req.datalen;
-		req.flags            = 0;
-
-		DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
-		ctdb_packet_dump(&req.hdr);
-
-		iov[0].iov_base = &req;
-		iov[0].iov_len = offsetof(struct ctdb_req_control, data);
-		iov[1].iov_base = vnn->srvids;
-		iov[1].iov_len = req.datalen;
-
-		nwritten = write_data_iov(conn->fd, iov, ARRAY_SIZE(iov));
-		if (nwritten == -1) {
-			DEBUG(10, ("write_data_iov failed: %s\n",
-				   strerror(errno)));
-			goto fail;
-		}
-	}
-
-	num_received = 0;
-
-	while (num_received < num_vnns) {
-		struct ctdb_req_header *hdr;
-		struct ctdb_reply_control *reply;
-		struct ctdb_vnn_list *vnn;
-		uint32_t reqid;
-		uint8_t *reply_data;
-		int ret;
-
-		ret = ctdb_read_req(conn, 0, talloc_tos(), &hdr);
-		if (ret != 0) {
-			DEBUG(10, ("ctdb_read_req failed: %s\n",
-				   strerror(ret)));
-			goto fail;
-		}
-
-		if (hdr->operation != CTDB_REPLY_CONTROL) {
-			DEBUG(1, ("Received invalid reply %u\n",
-				  (unsigned)hdr->operation));
-			goto fail;
-		}
-		reply = (struct ctdb_reply_control *)hdr;
-
-		reqid = reply->hdr.reqid;
-
-		DEBUG(10, ("Received reqid %d\n", (int)reqid));
-
-		for (i=0; i<num_vnns; i++) {
-			if (reqid == vnns[i].reqid) {
-				break;
-			}
-		}
-		if (i == num_vnns) {
-			DEBUG(1, ("Received unknown reqid number %u\n",
-				  (unsigned)reqid));
-			goto fail;
-		}
-
-		DEBUG(10, ("Found index %u\n", i));
-


-- 
Samba Shared Repository



More information about the samba-cvs mailing list