summaryrefslogtreecommitdiff
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-08-08 10:43:44 +1000
committerAmitay Isaacs <amitay@samba.org>2014-08-21 04:46:13 +0200
commit26a02a64cda0501d57db686dee61fda0846083ee (patch)
tree0d94f5323a5a67d49a4b2f2d1d4a012974579c31 /ctdb/tools
parent47e7440be9ab422b3b2544c0b071fb8717a7a915 (diff)
downloadsamba-26a02a64cda0501d57db686dee61fda0846083ee.tar.gz
ctdb-tools: Factor out new function find_node_xpnn() from control_xpnn()
Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
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)