added ctdb_connect_wait()
authorAndrew Tridgell <tridge@samba.org>
Thu, 30 Nov 2006 21:58:08 +0000 (08:58 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 30 Nov 2006 21:58:08 +0000 (08:58 +1100)
(This used to be ctdb commit 0a033f04bbc17db1aaa3a4458149e1e6b055cb9a)

ctdb/common/ctdb.c

index 6ab4b16702ff89b684763a795a249d6dc2a4c3c6..1ab1f8ab86b5653729d7bb63a9fcf0062d601303 100644 (file)
@@ -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 = {