fix the queueing for partially connected tcp sockets
authorAndrew Tridgell <tridge@samba.org>
Tue, 10 Apr 2007 10:48:31 +0000 (20:48 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 10 Apr 2007 10:48:31 +0000 (20:48 +1000)
(This used to be ctdb commit 55f1c2442a53a547302669a4fdd0f1c1deeed930)

ctdb/tcp/ctdb_tcp.h
ctdb/tcp/tcp_connect.c
ctdb/tcp/tcp_init.c

index 4fa496cd5ac1508b28749a29de4e9bc784df7778..50cde530f02ab840ecd914757faeddc342bfb4cd 100644 (file)
@@ -48,5 +48,6 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb);
 void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, 
                           struct timeval t, void *private);
 void ctdb_tcp_read_cb(uint8_t *data, size_t cnt, void *args);
+void ctdb_tcp_tnode_cb(uint8_t *data, size_t cnt, void *private);
 
 #define CTDB_TCP_ALIGNMENT 8
index d21720758bf9f0c85740fcc5d03efd0fa5bbcd16..27928c071e554523d4b55ed51e5e5dcfc5c2ad7a 100644 (file)
@@ -37,7 +37,7 @@ static void set_nonblocking(int fd)
 /*
   called when a complete packet has come in - should not happen on this socket
  */
-static void ctdb_tcp_tnode_cb(uint8_t *data, size_t cnt, void *private)
+void ctdb_tcp_tnode_cb(uint8_t *data, size_t cnt, void *private)
 {
        struct ctdb_node *node = talloc_get_type(private, struct ctdb_node);
        struct ctdb_tcp_node *tnode = talloc_get_type(node->private, 
@@ -80,8 +80,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
        
         setsockopt(tnode->fd,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one));
 
-       tnode->queue = ctdb_queue_setup(node->ctdb, node, tnode->fd, CTDB_TCP_ALIGNMENT,
-                                       ctdb_tcp_tnode_cb, node);
+       ctdb_queue_set_fd(tnode->queue, tnode->fd);
 
        /* tell the ctdb layer we are connected */
        node->ctdb->upcalls->node_connected(node);
index 52a6f2bcc7e44d0578db6e7831efe24ccaa9bee6..d9725a0e62e7e5e4943e7bfa223bd5c86ef521ff 100644 (file)
@@ -67,6 +67,10 @@ static int ctdb_tcp_add_node(struct ctdb_node *node)
 
        tnode->fd = -1;
        node->private = tnode;
+
+       tnode->queue = ctdb_queue_setup(node->ctdb, node, tnode->fd, CTDB_TCP_ALIGNMENT,
+                                       ctdb_tcp_tnode_cb, node);
+       
        return 0;
 }