Deferred attach : at early startup, defer any db attach calls until we are out of...
[sahlberg/ctdb.git] / tcp / tcp_init.c
index 737bd8e4a54c37e9555483c9767d5a737c30c626..95141d5610d8b283d84412c4208b9413f7d1d250 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/network.h"
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
@@ -27,7 +27,7 @@
 
 static int tnode_destructor(struct ctdb_tcp_node *tnode)
 {
-       struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
+  //   struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
 
        if (tnode->fd != -1) {
                close(tnode->fd);
@@ -51,7 +51,7 @@ static int ctdb_tcp_add_node(struct ctdb_node *node)
        talloc_set_destructor(tnode, tnode_destructor);
 
        tnode->out_queue = ctdb_queue_setup(node->ctdb, node, tnode->fd, CTDB_TCP_ALIGNMENT,
-                                       ctdb_tcp_tnode_cb, node);
+                                           ctdb_tcp_tnode_cb, node, "to-node-%s", node->name);
        
        return 0;
 }
@@ -69,7 +69,10 @@ static int ctdb_tcp_initialise(struct ctdb_context *ctdb)
                exit(1);
        }
 
-       for (i=0; i<ctdb->num_nodes; i++) {
+       for (i=0; i < ctdb->num_nodes; i++) {
+               if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
+                       continue;
+               }
                if (ctdb_tcp_add_node(ctdb->nodes[i]) != 0) {
                        DEBUG(DEBUG_CRIT, ("methods->add_node failed at %d\n", i));
                        return -1;
@@ -135,7 +138,10 @@ static int ctdb_tcp_start(struct ctdb_context *ctdb)
 {
        int i;
 
-       for (i=0; i<ctdb->num_nodes; i++) {
+       for (i=0; i < ctdb->num_nodes; i++) {
+               if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
+                       continue;
+               }
                ctdb_tcp_connect_node(ctdb->nodes[i]);
        }