From 2b68d143cbb779206a9afe10e3d182a60427654b Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 27 Aug 2013 14:46:08 +1000 Subject: [PATCH] tools/ctdb: Pass memory context for returning nodes in parse_nodestring Signed-off-by: Amitay Isaacs (This used to be ctdb commit 1585a8e275b0143e5e46311b3d5e9785119f735f) --- ctdb/tests/src/ctdb_tool_libctdb.c | 2 +- ctdb/tools/ctdb.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ctdb/tests/src/ctdb_tool_libctdb.c b/ctdb/tests/src/ctdb_tool_libctdb.c index e7e191a1bad..7b6e6ca273e 100644 --- a/ctdb/tests/src/ctdb_tool_libctdb.c +++ b/ctdb/tests/src/ctdb_tool_libctdb.c @@ -146,7 +146,7 @@ static void test_parse_nodestring(const char *nodestring_s, libctdb_test_read_nodemap(ctdb); - if (parse_nodestring(NULL, nodestring, CTDB_CURRENT_NODE, dd_ok, + if (parse_nodestring(NULL, NULL, nodestring, CTDB_CURRENT_NODE, dd_ok, &nodes, &pnn_mode)) { print_nodes(nodes, pnn_mode); } diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index b802f5e9bf8..55290681684 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -166,13 +166,14 @@ static TDB_DATA hextodata(TALLOC_CTX *mem_ctx, const char *str) * explicitly specified. */ static bool parse_nodestring(struct ctdb_context *ctdb, + TALLOC_CTX *mem_ctx, const char * nodestring, uint32_t current_pnn, bool dd_ok, uint32_t **nodes, uint32_t *pnn_mode) { - TALLOC_CTX *tmp_ctx = talloc_new(ctdb); + TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx); int n; uint32_t i; struct ctdb_node_map *nodemap; @@ -188,7 +189,7 @@ static bool parse_nodestring(struct ctdb_context *ctdb, } if (nodestring != NULL) { - *nodes = talloc_array(tmp_ctx, uint32_t, 0); + *nodes = talloc_array(mem_ctx, uint32_t, 0); if (*nodes == NULL) { goto failed; } @@ -205,7 +206,7 @@ static bool parse_nodestring(struct ctdb_context *ctdb, NODE_FLAGS_DELETED)) && !dd_ok) { continue; } - *nodes = talloc_realloc(tmp_ctx, *nodes, + *nodes = talloc_realloc(mem_ctx, *nodes, uint32_t, n+1); if (*nodes == NULL) { goto failed; @@ -240,7 +241,7 @@ static bool parse_nodestring(struct ctdb_context *ctdb, exit(10); } - *nodes = talloc_realloc(ctdb, *nodes, + *nodes = talloc_realloc(mem_ctx, *nodes, uint32_t, n+1); if (*nodes == NULL) { goto failed; @@ -261,7 +262,7 @@ static bool parse_nodestring(struct ctdb_context *ctdb, } } else { /* default - no nodes specified */ - *nodes = talloc_array(tmp_ctx, uint32_t, 1); + *nodes = talloc_array(mem_ctx, uint32_t, 1); if (*nodes == NULL) { goto failed; } @@ -1057,7 +1058,7 @@ static int control_nodestatus(struct ctdb_context *ctdb, int argc, const char ** usage(); } - if (!parse_nodestring(ctdb, argc == 1 ? argv[0] : NULL, + if (!parse_nodestring(ctdb, tmp_ctx, argc == 1 ? argv[0] : NULL, options.pnn, true, &nodes, &pnn_mode)) { return -1; } @@ -6321,7 +6322,7 @@ int main(int argc, const char *argv[]) } /* setup the node number(s) to contact */ - if (!parse_nodestring(ctdb, nodestring, CTDB_CURRENT_NODE, false, + if (!parse_nodestring(ctdb, ctdb, nodestring, CTDB_CURRENT_NODE, false, &options.nodes, &options.pnn)) { usage(); } -- 2.11.4.GIT