diff options
author | Martin Schwenke <martin@meltin.net> | 2015-11-03 16:36:34 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2015-11-23 02:31:11 +0100 |
commit | e73496d0dc2b8485a808f57d149856baf8a93b72 (patch) | |
tree | 3de45788cb2baa7a2dcbb2ad0b4782881c7aab07 /ctdb | |
parent | 47c5e5aa14328a4cbe147dd1ef77f6fd9c69fd5c (diff) | |
download | samba-e73496d0dc2b8485a808f57d149856baf8a93b72.tar.gz |
ctdb-ipalloc: Move memory allocation into ipalloc_state_init()
This puts all of the memory allocation for ipalloc_state into its init
function. This also simplifies the code because
set_ipflags_internal() can no longer fail because it no longer
allocates memory.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/server/ctdb_takeover.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 4391151db7b..33f99075ff7 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2360,20 +2360,14 @@ static uint32_t *get_tunable_from_nodes(struct ctdb_context *ctdb, * else * Set NOIPHOST ip flags for disabled nodes */ -static bool set_ipflags_internal(struct ipalloc_state *ipalloc_state, +static void set_ipflags_internal(struct ipalloc_state *ipalloc_state, struct ctdb_node_map_old *nodemap, uint32_t *tval_noiptakeover, uint32_t *tval_noiphostonalldisabled) { int i; - /* Clear IP flags - implicit due to talloc_zero */ - ipalloc_state->ipflags = - talloc_zero_array(ipalloc_state, struct ctdb_ipflags, nodemap->num); - if (ipalloc_state->ipflags == NULL) { - DEBUG(DEBUG_ERR, (__location__ " out of memory\n")); - return false; - } + /* IP flags cleared at this point - implicit due to talloc_zero */ for (i=0;i<nodemap->num;i++) { /* Can not take IPs on node with NoIPTakeover set */ @@ -2406,8 +2400,6 @@ static bool set_ipflags_internal(struct ipalloc_state *ipalloc_state, } } } - - return true; } static bool set_ipflags(struct ctdb_context *ctdb, @@ -2416,7 +2408,6 @@ static bool set_ipflags(struct ctdb_context *ctdb, { uint32_t *tval_noiptakeover; uint32_t *tval_noiphostonalldisabled; - bool ret; tval_noiptakeover = get_tunable_from_nodes(ctdb, ipalloc_state, nodemap, "NoIPTakeover", 0); @@ -2432,14 +2423,14 @@ static bool set_ipflags(struct ctdb_context *ctdb, return false; } - ret = set_ipflags_internal(ipalloc_state, nodemap, - tval_noiptakeover, - tval_noiphostonalldisabled); + set_ipflags_internal(ipalloc_state, nodemap, + tval_noiptakeover, + tval_noiphostonalldisabled); talloc_free(tval_noiptakeover); talloc_free(tval_noiphostonalldisabled); - return ret; + return true; } static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb, @@ -2471,6 +2462,15 @@ static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb, talloc_free(ipalloc_state); return NULL; } + ipalloc_state->ipflags = + talloc_zero_array(ipalloc_state, + struct ctdb_ipflags, + ipalloc_state->num); + if (ipalloc_state->ipflags == NULL) { + DEBUG(DEBUG_ERR, (__location__ " out of memory\n")); + talloc_free(ipalloc_state); + return NULL; + } if (1 == ctdb->tunable.lcp2_public_ip_assignment) { ipalloc_state->algorithm = IPALLOC_LCP2; |