diff options
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_daemon.c | 11 | ||||
-rw-r--r-- | ctdb/server/ctdb_server.c | 14 |
2 files changed, 10 insertions, 15 deletions
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 6a4e42d8010..e9fbc29cb98 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1374,21 +1374,18 @@ static void ctdb_initialise_vnn_map(struct ctdb_context *ctdb) static void ctdb_set_my_pnn(struct ctdb_context *ctdb) { - int nodeid; - if (ctdb->address == NULL) { ctdb_fatal(ctdb, "Can not determine PNN - node address is not set\n"); } - nodeid = ctdb_ip_to_nodeid(ctdb, ctdb->address); - if (nodeid == -1) { + ctdb->pnn = ctdb_ip_to_pnn(ctdb, ctdb->address); + if (ctdb->pnn == CTDB_UNKNOWN_PNN) { ctdb_fatal(ctdb, - "Can not determine PNN - node address not found in node list\n"); + "Can not determine PNN - unknown node address\n"); } - ctdb->pnn = ctdb->nodes[nodeid]->pnn; - DEBUG(DEBUG_NOTICE, ("PNN is %u\n", ctdb->pnn)); + D_NOTICE("PNN is %u\n", ctdb->pnn); } /* diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c index eb11eb1f95c..dcd761a2961 100644 --- a/ctdb/server/ctdb_server.c +++ b/ctdb/server/ctdb_server.c @@ -45,24 +45,22 @@ int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport) return 0; } -/* - Check whether an ip is a valid node ip - Returns the node id for this ip address or -1 -*/ -int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip) +/* Return the PNN for nodeip, CTDB_UNKNOWN_PNN if nodeip is invalid */ +uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb, + const ctdb_sock_addr *nodeip) { - int nodeid; + unsigned int nodeid; for (nodeid=0;nodeid<ctdb->num_nodes;nodeid++) { if (ctdb->nodes[nodeid]->flags & NODE_FLAGS_DELETED) { continue; } if (ctdb_same_ip(&ctdb->nodes[nodeid]->address, nodeip)) { - return nodeid; + return ctdb->nodes[nodeid]->pnn; } } - return -1; + return CTDB_UNKNOWN_PNN; } /* Load a nodes list file into a nodes array */ |