Rev 346: make sure we find out about new nodes as fast as possible
in http://samba.org/~tridge/ctdb
tridge at samba.org
tridge at samba.org
Fri May 25 12:07:45 GMT 2007
------------------------------------------------------------
revno: 346
revision-id: tridge at samba.org-20070525120745-40ik47s270sgbx07
parent: tridge at samba.org-20070525112726-m22jkf53zf4xkfpc
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Fri 2007-05-25 22:07:45 +1000
message:
make sure we find out about new nodes as fast as possible
modified:
tcp/ctdb_tcp.h ctdb_tcp.h-20061127103747-l8xeniwiapbydehq-3
tcp/tcp_connect.c tcp_connect.c-20061128004937-x70q1cu5xzg5g2tm-1
=== modified file 'tcp/ctdb_tcp.h'
--- a/tcp/ctdb_tcp.h 2007-04-13 10:38:24 +0000
+++ b/tcp/ctdb_tcp.h 2007-05-25 12:07:45 +0000
@@ -39,6 +39,8 @@
struct ctdb_tcp_node {
int fd;
struct ctdb_queue *queue;
+ struct fd_event *connect_fde;
+ struct timed_event *connect_te;
};
=== modified file 'tcp/tcp_connect.c'
--- a/tcp/tcp_connect.c 2007-05-15 08:40:56 +0000
+++ b/tcp/tcp_connect.c 2007-05-25 12:07:45 +0000
@@ -50,6 +50,7 @@
/* start a new connect cycle to try to re-establish the
link */
ctdb_queue_set_fd(tnode->queue, -1);
+ tnode->fd = -1;
event_add_timed(node->ctdb->ev, node, timeval_zero(),
ctdb_tcp_node_connect, node);
}
@@ -69,6 +70,9 @@
socklen_t len = sizeof(error);
int one = 1;
+ talloc_free(tnode->connect_te);
+ tnode->connect_te = NULL;
+
if (getsockopt(tnode->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 ||
error != 0) {
talloc_free(fde);
@@ -120,6 +124,13 @@
struct sockaddr_in sock_in;
struct sockaddr_in sock_out;
+ if (tnode->fd != -1) {
+ talloc_free(tnode->connect_fde);
+ tnode->connect_fde = NULL;
+ close(tnode->fd);
+ tnode->fd = -1;
+ }
+
tnode->fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
set_nonblocking(tnode->fd);
@@ -163,8 +174,15 @@
}
/* non-blocking connect - wait for write event */
- event_add_fd(node->ctdb->ev, node, tnode->fd, EVENT_FD_WRITE|EVENT_FD_READ,
- ctdb_node_connect_write, node);
+ tnode->connect_fde = event_add_fd(node->ctdb->ev, node, tnode->fd,
+ EVENT_FD_WRITE|EVENT_FD_READ,
+ ctdb_node_connect_write, node);
+
+ /* don't give it long to connect - retry in one second. This ensures
+ that we find a node is up quickly (tcp normally backs off a syn reply
+ delay by quite a lot) */
+ tnode->connect_te = event_add_timed(ctdb->ev, node, timeval_current_ofs(1, 0),
+ ctdb_tcp_node_connect, node);
}
/*
More information about the samba-cvs
mailing list