mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
tools/ctdb: Pass memory context for returning nodes in parse_nodestring
Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 1585a8e275b0143e5e46311b3d5e9785119f735f)
This commit is contained in:
parent
d4643abe88
commit
2b68d143cb
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user