summaryrefslogtreecommitdiff
path: root/ctdb/tools
diff options
context:
space:
mode:
Diffstat (limited to 'ctdb/tools')
-rw-r--r--ctdb/tools/ctdb.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 3b158fd7cdb..21ff366b179 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -885,14 +885,12 @@ static struct pnn_node *read_nodes_file(TALLOC_CTX *mem_ctx)
discover the pnn by loading the nodes file and try to bind to all
addresses one at a time until the ip address is found.
*/
-static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+static int find_node_xpnn(void)
{
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct pnn_node *pnn_nodes;
struct pnn_node *pnn_node;
- assert_single_node_only();
-
pnn_nodes = read_nodes_file(mem_ctx);
if (pnn_nodes == NULL) {
DEBUG(DEBUG_ERR,("Failed to read nodes file\n"));
@@ -902,9 +900,8 @@ static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
if (ctdb_sys_have_ip(&pnn_node->addr)) {
- printf("PNN:%d\n", pnn_node->pnn);
talloc_free(mem_ctx);
- return 0;
+ return pnn_node->pnn;
}
}
@@ -913,6 +910,21 @@ static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
return -1;
}
+static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ uint32_t pnn;
+
+ assert_single_node_only();
+
+ pnn = find_node_xpnn();
+ if (pnn == -1) {
+ return -1;
+ }
+
+ printf("PNN:%d\n", pnn);
+ return 0;
+}
+
/* Helpers for ctdb status
*/
static bool is_partially_online(struct ctdb_context *ctdb, struct ctdb_node_and_flags *node)