queue up packets to nodes that aren't connected yet. This avoids a
authorAndrew Tridgell <tridge@samba.org>
Fri, 1 Dec 2006 04:54:15 +0000 (15:54 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 1 Dec 2006 04:54:15 +0000 (15:54 +1100)
startup race condition in the test suite

(This used to be ctdb commit b623ac755de843a3386a7c0e882d651b7f20d482)

ctdb/tcp/tcp_connect.c
ctdb/tcp/tcp_io.c

index 9fc322fde5bf7a91f8d2caf1cad2d5724da6e320..6074b646aa4e9776474f1d52209b8ff89bd97379 100644 (file)
@@ -63,6 +63,10 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
 
        /* tell the ctdb layer we are connected */
        node->ctdb->upcalls->node_connected(node);
+
+       if (tnode->queue) {
+               EVENT_FD_WRITEABLE(tnode->fde);         
+       }
 }
 
 /*
index 67a6bc4b3b456b4b518f6b01800530c40d11f867..d572ba533fda7f6baf05d398288b0885971b4c13 100644 (file)
@@ -151,14 +151,9 @@ int ctdb_tcp_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t length)
                                                      struct ctdb_tcp_node);
        struct ctdb_tcp_packet *pkt;
        
-       if (tnode->fd == -1) {
-               ctdb_set_error(node->ctdb, "Sending to dead node %s\n", node->name);
-               return -1;
-       }
-
        /* if the queue is empty then try an immediate write, avoiding
           queue overhead. This relies on non-blocking sockets */
-       if (tnode->queue == NULL) {
+       if (tnode->queue == NULL && tnode->fd != -1) {
                ssize_t n = write(tnode->fd, data, length);
                if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
                        event_add_timed(node->ctdb->ev, node, timeval_zero(), 
@@ -182,7 +177,7 @@ int ctdb_tcp_queue_pkt(struct ctdb_node *node, uint8_t *data, uint32_t length)
 
        pkt->length = length;
 
-       if (tnode->queue == NULL) {
+       if (tnode->queue == NULL && tnode->fd != -1) {
                EVENT_FD_WRITEABLE(tnode->fde);
        }