When we reload the nodes file
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 7 Oct 2008 07:12:54 +0000 (18:12 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 7 Oct 2008 07:12:54 +0000 (18:12 +1100)
instead of shutting down/restarting the entire tcp layer
just bounce all outgoing connections and reconnect

server/ctdb_recover.c
tcp/tcp_init.c

index dc6533cb3f3db019f88f67762233c0ff46118ae7..46ea99f5a20b15bd59f5bca4d79c5c37876c0b7a 100644 (file)
@@ -179,27 +179,18 @@ ctdb_reload_nodes_event(struct event_context *ev, struct timed_event *te,
                               struct timeval t, void *private_data)
 {
        int ret;
-       struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
-       int ctdb_tcp_init(struct ctdb_context *);
+       int i;
 
-       /* shut down the transport */
-       if (ctdb->methods != NULL) {
-               ctdb->methods->shutdown(ctdb);
-       }
+       struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
 
-       /* start the transport again */
        ctdb_load_nodes_file(ctdb);
-       ret = ctdb_tcp_init(ctdb);
-       if (ret != 0) {
-               DEBUG(DEBUG_CRIT, (__location__ " Failed to init TCP\n"));
-               exit(1);
-       }
 
-       if (ctdb->methods == NULL) {
-               DEBUG(DEBUG_ALERT,(__location__ " Can not restart transport. ctdb->methods==NULL\n"));
-               ctdb_fatal(ctdb, "can not reinitialize transport.");
+       for (i=0; i<ctdb->num_nodes; i++) {
+               if (ctdb->methods->add_node(ctdb->nodes[i]) != 0) {
+                       DEBUG(DEBUG_CRIT, (__location__ " methods->add_node failed at %d\n", i));
+                       ctdb_fatal(ctdb, "failed to add node. shutting down\n");
+               }
        }
-       ctdb->methods->initialise(ctdb);
        ctdb->methods->start(ctdb);
 
        return;
index 5c53caf6cd9db2387ab997424c7a1d42221abeb0..8b33efeb067dc3c80ab1adca2492bf7139409e7b 100644 (file)
 */
 static int ctdb_tcp_add_node(struct ctdb_node *node)
 {
-       struct ctdb_tcp *ctcp = talloc_get_type(node->ctdb->private_data,
-                                               struct ctdb_tcp);
        struct ctdb_tcp_node *tnode;
-       tnode = talloc_zero(ctcp, struct ctdb_tcp_node);
+       tnode = talloc_zero(node, struct ctdb_tcp_node);
        CTDB_NO_MEMORY(node->ctdb, tnode);
 
        tnode->fd = -1;
        node->private_data = tnode;
 
-       tnode->out_queue = ctdb_queue_setup(node->ctdb, ctcp, tnode->fd, CTDB_TCP_ALIGNMENT,
+       tnode->out_queue = ctdb_queue_setup(node->ctdb, node, tnode->fd, CTDB_TCP_ALIGNMENT,
                                        ctdb_tcp_tnode_cb, node);
        
        return 0;