[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Fri Feb 12 07:41:04 UTC 2016


The branch, master has been updated
       via  2deba05 ctdb-ipalloc: Remove most uses of struct ctdb_public_ip_list_old
       via  53752bc ctdb-ipalloc: Use goto fail to avoid repetition
       via  96123dd ctdb-tests: Remove unnecessary \ from transaction data
       via  b8fa065 ctdb-tests: Improve ctdb detach test
       via  7c1d4b9 ctdb-tests: Remove last remaining instance of ctdb -n all
       via  157e19b ctdb-recovery: Add a log message when marshalling recovery database fails
       via  d1f3b5d ctdb-daemon: Improve log message when REQ_DMASTER is received on non-lmaster
      from  d66f2c8 param: Fix str_list_v3 to accept ; again

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


- Log -----------------------------------------------------------------
commit 2deba05c5865211c39a67247e4aabb9257125f58
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 1 16:12:03 2015 +1100

    ctdb-ipalloc: Remove most uses of struct ctdb_public_ip_list_old
    
    Where possible, this should no longer be used.
    
    struct ctdb_public_ip_list is a fixed size structure and introduces an
    extra level of indirection.  This means one level of indirection can
    be dropped for known_public_ips and available_public_ips.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Fri Feb 12 08:40:21 CET 2016 on sn-devel-144

commit 53752bcf2960141c7b982a085866ef98a9f05ecb
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Dec 1 14:00:43 2015 +1100

    ctdb-ipalloc: Use goto fail to avoid repetition
    
    This is getting unreadable...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 96123dd4632c48e089631ec6064dccc2c29c2490
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 6 17:10:07 2015 +1100

    ctdb-tests: Remove unnecessary \ from transaction data
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b8fa065843267bbfa8fa222bd7e1ee7004d35de0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Nov 6 14:48:44 2015 +1100

    ctdb-tests: Improve ctdb detach test
    
    Confirm that after re-attaching detached database, it is empty.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 7c1d4b9abb009d21c80b6d205e4f42ddcdce7950
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Nov 5 16:11:59 2015 +1100

    ctdb-tests: Remove last remaining instance of ctdb -n all
    
    _cluster_is_recovered() is used to check if all the nodes in the
    cluster have recovery mode set to NORMAL.  This is mainly used just
    after recovery to wait till the recovery is over.  Instead just check
    the recovery mode on node 0.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 157e19b9848c4745e2a9a2169e25698cfd4dcaa6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Feb 10 11:39:37 2016 +1100

    ctdb-recovery: Add a log message when marshalling recovery database fails
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit d1f3b5d408ef7e69725c31dbc510cec5ae8a1f56
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 3 17:43:44 2015 +1100

    ctdb-daemon: Improve log message when REQ_DMASTER is received on non-lmaster
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/server/ctdb_call.c              |  7 ++--
 ctdb/server/ctdb_recovery_helper.c   |  2 +
 ctdb/server/ctdb_takeover.c          | 75 +++++++++++++++++++++---------------
 ctdb/server/ipalloc.h                |  6 +--
 ctdb/server/ipalloc_common.c         |  8 ++--
 ctdb/tests/scripts/integration.bash  |  2 +-
 ctdb/tests/simple/27_ctdb_detach.sh  | 12 ++++++
 ctdb/tests/simple/55_ctdb_ptrans.sh  |  6 +--
 ctdb/tests/src/ctdb_takeover_tests.c | 61 +++++++++++++----------------
 9 files changed, 99 insertions(+), 80 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 2461f95..510be7d 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -620,9 +620,10 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 	}
 
 	if (ctdb_lmaster(ctdb, &key) != ctdb->pnn) {
-		DEBUG(DEBUG_ALERT,("pnn %u dmaster request to non-lmaster lmaster=%u gen=%u curgen=%u\n",
-			 ctdb->pnn, ctdb_lmaster(ctdb, &key), 
-			 hdr->generation, ctdb->vnn_map->generation));
+		DEBUG(DEBUG_ERR, ("dmaster request to non-lmaster "
+				  "db=%s lmaster=%u gen=%u curgen=%u\n",
+				  ctdb_db->db_name, ctdb_lmaster(ctdb, &key),
+				  hdr->generation, ctdb_db->generation));
 		ctdb_fatal(ctdb, "ctdb_req_dmaster to non-lmaster");
 	}
 
diff --git a/ctdb/server/ctdb_recovery_helper.c b/ctdb/server/ctdb_recovery_helper.c
index 8fc2791..8c2c9e4 100644
--- a/ctdb/server/ctdb_recovery_helper.c
+++ b/ctdb/server/ctdb_recovery_helper.c
@@ -270,6 +270,8 @@ static struct ctdb_rec_buffer *recdb_records(struct recdb_context *recdb,
 
 	ret = tdb_traverse_read(recdb->db->tdb, recdb_traverse, &state);
 	if (ret == -1 || state.failed) {
+		LOG("Failed to marshall recovery records for %s\n",
+		    recdb->db_name);
 		TALLOC_FREE(state.recbuf);
 		return NULL;
 	}
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index a613aa0..cdb4601 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -1254,7 +1254,7 @@ static int getips_count_callback(void *param, void *data)
 }
 
 static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
-				       struct ctdb_public_ip_list_old *ips,
+				       struct ctdb_public_ip_list *ips,
 				       uint32_t pnn);
 
 static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
@@ -1263,6 +1263,7 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
 {
 	int j;
 	int ret;
+	struct ctdb_public_ip_list_old *ip_list;
 
 	if (ipalloc_state->num != nodemap->num) {
 		DEBUG(DEBUG_ERR,
@@ -1283,18 +1284,25 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
 					j,
 					ipalloc_state->known_public_ips,
 					0,
-					&ipalloc_state->known_public_ips[j]);
+					&ip_list);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,
 			      ("Failed to read known public IPs from node: %u\n",
 			       j));
 			return -1;
 		}
+		ipalloc_state->known_public_ips[j].num = ip_list->num;
+		/* This could be copied and freed.  However, ip_list
+		 * is allocated off ipalloc_state->known_public_ips,
+		 * so this is a safe hack.  This will go away in a
+		 * while anyway... */
+		ipalloc_state->known_public_ips[j].ip = &ip_list->ips[0];
 
 		if (ctdb->do_checkpublicip) {
-			verify_remote_ip_allocation(ctdb,
-						    ipalloc_state->known_public_ips[j],
-						    j);
+			verify_remote_ip_allocation(
+				ctdb,
+				&ipalloc_state->known_public_ips[j],
+				j);
 		}
 
 		/* Retrieve the list of available public IPs from the node */
@@ -1303,13 +1311,19 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
 					j,
 					ipalloc_state->available_public_ips,
 					CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE,
-					&ipalloc_state->available_public_ips[j]);
+					&ip_list);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,
 			      ("Failed to read available public IPs from node: %u\n",
 			       j));
 			return -1;
 		}
+		ipalloc_state->available_public_ips[j].num = ip_list->num;
+		/* This could be copied and freed.  However, ip_list
+		 * is allocated off ipalloc_state->available_public_ips,
+		 * so this is a safe hack.  This will go away in a
+		 * while anyway... */
+		ipalloc_state->available_public_ips[j].ip = &ip_list->ips[0];
 	}
 
 	return 0;
@@ -1320,13 +1334,13 @@ create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_s
 {
 	int i, j;
 	struct public_ip_list *ip_list;
-	struct ctdb_public_ip_list_old *public_ips;
+	struct ctdb_public_ip_list *public_ips;
 
 	TALLOC_FREE(ctdb->ip_tree);
 	ctdb->ip_tree = trbt_create(ctdb, 0);
 
 	for (i=0; i < ctdb->num_nodes; i++) {
-		public_ips = ipalloc_state->known_public_ips[i];
+		public_ips = &ipalloc_state->known_public_ips[i];
 
 		if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
 			continue;
@@ -1344,16 +1358,16 @@ create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_s
 			CTDB_NO_MEMORY_NULL(ctdb, tmp_ip);
 			/* Do not use information about IP addresses hosted
 			 * on other nodes, it may not be accurate */
-			if (public_ips->ips[j].pnn == ctdb->nodes[i]->pnn) {
-				tmp_ip->pnn = public_ips->ips[j].pnn;
+			if (public_ips->ip[j].pnn == ctdb->nodes[i]->pnn) {
+				tmp_ip->pnn = public_ips->ip[j].pnn;
 			} else {
 				tmp_ip->pnn = -1;
 			}
-			tmp_ip->addr = public_ips->ips[j].addr;
+			tmp_ip->addr = public_ips->ip[j].addr;
 			tmp_ip->next = NULL;
 
 			trbt_insertarray32_callback(ctdb->ip_tree,
-				IP_KEYLEN, ip_key(&public_ips->ips[j].addr),
+				IP_KEYLEN, ip_key(&public_ips->ip[j].addr),
 				add_ip_callback,
 				tmp_ip);
 		}
@@ -1582,23 +1596,23 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
 	}
 
 	ipalloc_state->num = ctdb->num_nodes;
+
 	ipalloc_state->known_public_ips =
 		talloc_zero_array(ipalloc_state,
-				  struct ctdb_public_ip_list_old *,
+				  struct ctdb_public_ip_list,
 				  ipalloc_state->num);
 	if (ipalloc_state->known_public_ips == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		talloc_free(ipalloc_state);
-		return NULL;
+		goto fail;
 	}
+
 	ipalloc_state->available_public_ips =
 		talloc_zero_array(ipalloc_state,
-				  struct ctdb_public_ip_list_old *,
+				  struct ctdb_public_ip_list,
 				  ipalloc_state->num);
 	if (ipalloc_state->available_public_ips == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		talloc_free(ipalloc_state);
-		return NULL;
+		goto fail;
 	}
 	ipalloc_state->noiptakeover =
 		talloc_zero_array(ipalloc_state,
@@ -1606,8 +1620,7 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
 				  ipalloc_state->num);
 	if (ipalloc_state->noiptakeover == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		talloc_free(ipalloc_state);
-		return NULL;
+		goto fail;
 	}
 	ipalloc_state->noiphost =
 		talloc_zero_array(ipalloc_state,
@@ -1615,8 +1628,7 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
 				  ipalloc_state->num);
 	if (ipalloc_state->noiphost == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		talloc_free(ipalloc_state);
-		return NULL;
+		goto fail;
 	}
 
 	if (1 == ctdb->tunable.lcp2_public_ip_assignment) {
@@ -1630,6 +1642,9 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
 	ipalloc_state->no_ip_failback = ctdb->tunable.no_ip_failback;
 
 	return ipalloc_state;
+fail:
+	talloc_free(ipalloc_state);
+	return NULL;
 }
 
 struct iprealloc_callback_data {
@@ -1805,7 +1820,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodem
 	/* Short-circuit IP allocation if no node has available IPs */
 	can_host_ips = false;
 	for (i=0; i < ipalloc_state->num; i++) {
-		if (ipalloc_state->available_public_ips[i] != NULL) {
+		if (ipalloc_state->available_public_ips[i].num != 0) {
 			can_host_ips = true;
 		}
 	}
@@ -3460,7 +3475,7 @@ int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
    This is verified against ctdb->ip_tree
 */
 static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
-				       struct ctdb_public_ip_list_old *ips,
+				       struct ctdb_public_ip_list *ips,
 				       uint32_t pnn)
 {
 	struct public_ip_list *tmp_ip;
@@ -3477,22 +3492,22 @@ static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
 	}
 
 	for (i=0; i<ips->num; i++) {
-		tmp_ip = trbt_lookuparray32(ctdb->ip_tree, IP_KEYLEN, ip_key(&ips->ips[i].addr));
+		tmp_ip = trbt_lookuparray32(ctdb->ip_tree, IP_KEYLEN, ip_key(&ips->ip[i].addr));
 		if (tmp_ip == NULL) {
-			DEBUG(DEBUG_ERR,("Node %u has new or unknown public IP %s\n", pnn, ctdb_addr_to_str(&ips->ips[i].addr)));
+			DEBUG(DEBUG_ERR,("Node %u has new or unknown public IP %s\n", pnn, ctdb_addr_to_str(&ips->ip[i].addr)));
 			return -1;
 		}
 
-		if (tmp_ip->pnn == -1 || ips->ips[i].pnn == -1) {
+		if (tmp_ip->pnn == -1 || ips->ip[i].pnn == -1) {
 			continue;
 		}
 
-		if (tmp_ip->pnn != ips->ips[i].pnn) {
+		if (tmp_ip->pnn != ips->ip[i].pnn) {
 			DEBUG(DEBUG_ERR,
 			      ("Inconsistent IP allocation - node %u thinks %s is held by node %u while it is assigned to node %u\n",
 			       pnn,
-			       ctdb_addr_to_str(&ips->ips[i].addr),
-			       ips->ips[i].pnn, tmp_ip->pnn));
+			       ctdb_addr_to_str(&ips->ip[i].addr),
+			       ips->ip[i].pnn, tmp_ip->pnn));
 			return -1;
 		}
 	}
diff --git a/ctdb/server/ipalloc.h b/ctdb/server/ipalloc.h
index 65c7786..1acaf35 100644
--- a/ctdb/server/ipalloc.h
+++ b/ctdb/server/ipalloc.h
@@ -25,8 +25,6 @@
 #include "replace.h"
 #include "system/network.h"
 
-#include "include/ctdb_protocol.h"
-
 struct public_ip_list {
 	struct public_ip_list *next;
 	uint32_t pnn;
@@ -47,8 +45,8 @@ struct ipalloc_state {
 	uint32_t num;
 
 	/* Arrays with data for each node */
-	struct ctdb_public_ip_list_old **known_public_ips;
-	struct ctdb_public_ip_list_old **available_public_ips;
+	struct ctdb_public_ip_list *known_public_ips;
+	struct ctdb_public_ip_list *available_public_ips;
 	bool *noiptakeover;
 	bool *noiphost;
 
diff --git a/ctdb/server/ipalloc_common.c b/ctdb/server/ipalloc_common.c
index 9e4de59..c84359b 100644
--- a/ctdb/server/ipalloc_common.c
+++ b/ctdb/server/ipalloc_common.c
@@ -32,8 +32,6 @@
 #include "common/common.h"
 #include "common/rb_tree.h"
 
-#include "include/ctdb_protocol.h"
-
 #include "server/ipalloc_private.h"
 
 #define TAKEOVER_TIMEOUT() timeval_current_ofs(ctdb->tunable.takeover_timeout,0)
@@ -61,21 +59,21 @@ static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,
 			     int32_t pnn,
 			     struct public_ip_list *ip)
 {
-	struct ctdb_public_ip_list_old *public_ips;
+	struct ctdb_public_ip_list *public_ips;
 	int i;
 
 	if (ipalloc_state->noiphost[pnn]) {
 		return false;
 	}
 
-	public_ips = ipalloc_state->available_public_ips[pnn];
+	public_ips = &ipalloc_state->available_public_ips[pnn];
 
 	if (public_ips == NULL) {
 		return false;
 	}
 
 	for (i=0; i<public_ips->num; i++) {
-		if (ctdb_same_ip(&ip->addr, &public_ips->ips[i].addr)) {
+		if (ctdb_same_ip(&ip->addr, &public_ips->ip[i].addr)) {
 			/* yes, this node can serve this public ip */
 			return true;
 		}
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index e3fb3d4..67f4106 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -320,7 +320,7 @@ _cluster_is_healthy ()
 
 _cluster_is_recovered ()
 {
-    node_has_status all recovered
+    node_has_status 0 recovered
 }
 
 _cluster_is_ready ()
diff --git a/ctdb/tests/simple/27_ctdb_detach.sh b/ctdb/tests/simple/27_ctdb_detach.sh
index 4b7b3b5..42ec635 100755
--- a/ctdb/tests/simple/27_ctdb_detach.sh
+++ b/ctdb/tests/simple/27_ctdb_detach.sh
@@ -157,3 +157,15 @@ echo "Re-attach test database"
 try_command_on_node all $CTDB setvar AllowClientDBAttach 1
 try_command_on_node 0 $CTDB attach $testdb1
 check_db "$testdb1"
+
+echo
+echo "Check if the database is empty"
+try_command_on_node 0 $CTDB catdb $testdb1
+num_keys=$(echo "$out" | sed -n -e 's/Dumped \([0-9]*\) records/\1/p') || true
+if [ -n "$num_keys" -a $num_keys -eq 0 ]; then
+    echo "GOOD: Database $testdb1 is empty"
+else
+    echo "BAD: Database $testdb1 is not empty"
+    echo "$out"
+    exit 1
+fi
diff --git a/ctdb/tests/simple/55_ctdb_ptrans.sh b/ctdb/tests/simple/55_ctdb_ptrans.sh
index 14de67e..ba92899 100755
--- a/ctdb/tests/simple/55_ctdb_ptrans.sh
+++ b/ctdb/tests/simple/55_ctdb_ptrans.sh
@@ -42,7 +42,7 @@ try_command_on_node 0 $CTDB wipedb $TESTDB
 
 echo "Adding 3 records"
 
-items='\
+items='
 "key1" "value1"
 "key2" "value1"
 "key3" "value1"'
@@ -65,7 +65,7 @@ fi
 
 echo "Deleting 1 record, updating 1, adding 1 new record, 1 bogus input line"
 
-items='\
+items='
 "key1" ""
 "key2" "value2"
 "key3"
@@ -107,7 +107,7 @@ EOF
 
 echo "Deleting all records"
 
-items='\
+items='
 "key2" ""
 "key3" ""
 "key4" ""'
diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c
index bbd004e..a6c61cf 100644
--- a/ctdb/tests/src/ctdb_takeover_tests.c
+++ b/ctdb/tests/src/ctdb_takeover_tests.c
@@ -109,29 +109,25 @@ static bool
 read_ctdb_public_ip_info(TALLOC_CTX *ctx  ,
 			 int numnodes,
 			 struct public_ip_list ** all_ips,
-			 struct ctdb_public_ip_list_old *** known,
-			 struct ctdb_public_ip_list_old *** avail)
+			 struct ctdb_public_ip_list ** known,
+			 struct ctdb_public_ip_list ** avail)
 {
 	char line[1024];
 	ctdb_sock_addr addr;
 	char *t, *tok;
 	struct public_ip_list * ta;
 	int pnn, numips, curr, n, i;
-	struct ctdb_public_ip_list_old * a;
+	struct ctdb_public_ip_list * a;
 
 	struct public_ip_list *last = NULL;
 	enum ctdb_runstate *runstate;
 
 	runstate = get_runstate(ctx, numnodes);
 
-	*known = talloc_array_size(ctx, sizeof(struct ctdb_public_ip_list_old *), CTDB_TEST_MAX_NODES);
-	memset(*known, 0,
-	       sizeof(struct ctdb_public_ip_list_old *) * CTDB_TEST_MAX_NODES);
-
-	*avail = talloc_array_size(ctx, sizeof(struct ctdb_public_ip_list_old *),
+	*known = talloc_zero_array(ctx, struct ctdb_public_ip_list,
+				   CTDB_TEST_MAX_NODES);
+	*avail = talloc_zero_array(ctx, struct ctdb_public_ip_list,
 				   CTDB_TEST_MAX_NODES);
-	memset(*avail, 0,
-	       sizeof(struct ctdb_public_ip_list_old *) * CTDB_TEST_MAX_NODES);
 
 	numips = 0;
 	*all_ips = NULL;
@@ -195,39 +191,36 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx  ,
 		t = strtok(tok, ",");
 		while (t != NULL) {
 			n = (int) strtol(t, (char **) NULL, 10);
-			if ((*known)[n] == NULL) {
+			if ((*known)[n].num == 0) {
 				/* Array size here has to be
 				 * CTDB_TEST_MAX_IPS because total
 				 * number of IPs isn't yet known */
-				(*known)[n] = talloc_size(ctx,
-							  offsetof(struct ctdb_public_ip_list_old, ips) +
-							  CTDB_TEST_MAX_IPS * sizeof(struct ctdb_public_ip));
-				(*known)[n]->num = 0;
+				(*known)[n].ip = talloc_zero_array(
+					*known, struct ctdb_public_ip, CTDB_TEST_MAX_IPS);
 			}
-			curr = (*known)[n]->num;
-			(*known)[n]->ips[curr].pnn = pnn;
-			memcpy(&((*known)[n]->ips[curr].addr),
+			curr = (*known)[n].num;
+			(*known)[n].ip[curr].pnn = pnn;
+			memcpy(&((*known)[n].ip[curr].addr),
 			       &addr, sizeof(addr));
-			(*known)[n]->num++;
+			(*known)[n].num++;
 			t = strtok(NULL, ",");
 		}
 
 	}
 
 	/* Build list of all allowed IPs */
-	a = talloc_size(ctx,
-			offsetof(struct ctdb_public_ip_list_old, ips) +
-			numips * sizeof(struct ctdb_public_ip));
+	a = talloc(ctx, struct ctdb_public_ip_list);
+	a->ip = talloc_zero_array(a, struct ctdb_public_ip, numips);
 	a->num = numips;
 	for (ta = *all_ips, i=0; ta != NULL && i < numips ; ta = ta->next, i++) {
-		a->ips[i].pnn = ta->pnn;
-		memcpy(&(a->ips[i].addr), &(ta->addr), sizeof(ta->addr));
+		a->ip[i].pnn = ta->pnn;
+		memcpy(&(a->ip[i].addr), &(ta->addr), sizeof(ta->addr));
 	}
 
 	/* Assign it to any nodes that don't have a list assigned */
 	for (n = 0; n < numnodes; n++) {
-		if ((*known)[n] == NULL) {
-			(*known)[n] = a;
+		if ((*known)[n].num == 0) {
+			(*known)[n] = *a;
 		}
 		if (runstate[n] == CTDB_RUNSTATE_RUNNING) {
 			(*avail)[n] = (*known)[n];
@@ -238,17 +231,17 @@ read_ctdb_public_ip_info(TALLOC_CTX *ctx  ,
 }
 
 static void print_ctdb_available_ips(int numnodes,
-				     struct ctdb_public_ip_list_old **avail)
+				     struct ctdb_public_ip_list *avail)
 {
 	int n, i;
 
 	for (n = 0; n < numnodes; n++) {
-		if ((avail[n] != NULL) && (avail[n]->num > 0)) {
+		if (avail[n].num > 0) {
 			printf("%d:", n);
-			for (i = 0; i < avail[n]->num; i++) {
+			for (i = 0; i < avail[n].num; i++) {
 				printf("%s%s",
 				       (i == 0) ? " " : ", ",
-				       ctdb_addr_to_str(&(avail[n]->ips[i].addr)));
+				       ctdb_addr_to_str(&(avail[n].ip[i].addr)));
 			}
 			printf("\n");
 		}
@@ -259,8 +252,8 @@ static void ctdb_test_read_ctdb_public_ip_info(const char nodestates[])
 {
 	int numnodes;
 	struct public_ip_list *l;
-	struct ctdb_public_ip_list_old **known;
-	struct ctdb_public_ip_list_old **avail;
+	struct ctdb_public_ip_list *known;
+	struct ctdb_public_ip_list *avail;
 	char *tok, *ns;
 
 	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
@@ -437,8 +430,8 @@ static void ctdb_test_init(const char nodestates[],


-- 
Samba Shared Repository



More information about the samba-cvs mailing list