Rev 26: queue up packets to nodes that aren't connected yet. This avoids a in http://samba.org/~tridge/ctdb/

tridge at samba.org tridge at samba.org
Fri Dec 1 20:54:15 GMT 2006


------------------------------------------------------------
revno: 26
revision-id: tridge at samba.org-20061201045415-m377f8xq177vlehi
parent: tridge at samba.org-20061201044524-r6tknuvx120a4o7t
committer: Andrew Tridgell <tridge at samba.org>
branch nick: ctdb
timestamp: Fri 2006-12-01 15:54:15 +1100
message:
  queue up packets to nodes that aren't connected yet. This avoids a
  startup race condition in the test suite
modified:
  tcp/tcp_connect.c              tcp_connect.c-20061128004937-x70q1cu5xzg5g2tm-1
  tcp/tcp_io.c                   tcp_io.c-20061128004937-x70q1cu5xzg5g2tm-3
=== modified file 'tcp/tcp_connect.c'
--- a/tcp/tcp_connect.c	2006-12-01 04:54:15 +0000
+++ b/tcp/tcp_connect.c	2006-12-01 04:45:24 +0000
@@ -63,10 +63,6 @@
 
 	/* tell the ctdb layer we are connected */
 	node->ctdb->upcalls->node_connected(node);
-
-	if (tnode->queue) {
-		EVENT_FD_WRITEABLE(tnode->fde);		
-	}
 }
 
 /*

=== modified file 'tcp/tcp_io.c'
--- a/tcp/tcp_io.c	2006-12-01 04:54:15 +0000
+++ b/tcp/tcp_io.c	2006-12-01 04:45:24 +0000
@@ -151,9 +151,14 @@
 						      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 && tnode->fd != -1) {
+	if (tnode->queue == NULL) {
 		ssize_t n = write(tnode->fd, data, length);
 		if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
 			event_add_timed(node->ctdb->ev, node, timeval_zero(), 
@@ -177,7 +182,7 @@
 
 	pkt->length = length;
 
-	if (tnode->queue == NULL && tnode->fd != -1) {
+	if (tnode->queue == NULL) {
 		EVENT_FD_WRITEABLE(tnode->fde);
 	}
 



More information about the samba-cvs mailing list