From 375eeb8a245071c0aacda2c2ef53f31c6587eff3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Dec 2006 08:58:08 +1100 Subject: [PATCH] added ctdb_connect_wait() (This used to be ctdb commit 0a033f04bbc17db1aaa3a4458149e1e6b055cb9a) --- ctdb/common/ctdb.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 6ab4b16702f..1ab1f8ab86b 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -157,7 +157,9 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len */ static void ctdb_node_dead(struct ctdb_node *node) { - printf("%s: node %s is dead\n", node->ctdb->name, node->name); + node->ctdb->num_connected--; + printf("%s: node %s is dead: %d connected\n", + node->ctdb->name, node->name, node->ctdb->num_connected); } /* @@ -165,7 +167,19 @@ static void ctdb_node_dead(struct ctdb_node *node) */ static void ctdb_node_connected(struct ctdb_node *node) { - printf("%s: connected to %s\n", node->ctdb->name, node->name); + node->ctdb->num_connected++; + printf("%s: connected to %s - %d connected\n", + node->ctdb->name, node->name, node->ctdb->num_connected); +} + +/* + wait for all nodes to be connected +*/ +void ctdb_connect_wait(struct ctdb_context *ctdb) +{ + while (ctdb->num_connected != ctdb->num_nodes - 1) { + event_loop_once(ctdb->ev); + } } static const struct ctdb_upcalls ctdb_upcalls = {