diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-04 04:57:30 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:49:47 -0500 |
commit | a78be2150ba06738f4c7e85ca2980200d4a3c533 (patch) | |
tree | bc30c417b22a8cd51692635134f4c865a6023235 /source4/cluster/ctdb/tcp | |
parent | 690df3ccd98c586610cc5e528b05f7863b334a3c (diff) | |
download | samba-a78be2150ba06738f4c7e85ca2980200d4a3c533.tar.gz samba-a78be2150ba06738f4c7e85ca2980200d4a3c533.tar.bz2 samba-a78be2150ba06738f4c7e85ca2980200d4a3c533.zip |
r22070: merge in the changes from the bzr ctdb tree, and convert the brlock
ctdb backend to use the updated multi-database API
(This used to be commit 44dcac9e4d81bfc078512248967b6240db9d1bd8)
Diffstat (limited to 'source4/cluster/ctdb/tcp')
-rw-r--r-- | source4/cluster/ctdb/tcp/tcp_connect.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/source4/cluster/ctdb/tcp/tcp_connect.c b/source4/cluster/ctdb/tcp/tcp_connect.c index e828bb7cbb..fe0fc210ba 100644 --- a/source4/cluster/ctdb/tcp/tcp_connect.c +++ b/source4/cluster/ctdb/tcp/tcp_connect.c @@ -46,6 +46,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f struct ctdb_context *ctdb = node->ctdb; int error = 0; socklen_t len = sizeof(error); + int one = 1; if (getsockopt(tnode->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0 || error != 0) { @@ -64,11 +65,29 @@ 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); + setsockopt(tnode->fd,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one)); + if (tnode->queue) { EVENT_FD_WRITEABLE(tnode->fde); } } + +static int ctdb_tcp_get_address(struct ctdb_context *ctdb, + const char *address, struct in_addr *addr) +{ + if (inet_pton(AF_INET, address, addr) <= 0) { + struct hostent *he = gethostbyname(address); + if (he == NULL || he->h_length > sizeof(*addr)) { + ctdb_set_error(ctdb, "invalid nework address '%s'\n", + address); + return -1; + } + memcpy(addr, he->h_addr, he->h_length); + } + return 0; +} + /* called when we should try and establish a tcp connection to a node */ @@ -85,7 +104,9 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, set_nonblocking(tnode->fd); - inet_pton(AF_INET, node->address.address, &sock_out.sin_addr); + if (ctdb_tcp_get_address(ctdb, node->address.address, &sock_out.sin_addr) != 0) { + return; + } sock_out.sin_port = htons(node->address.port); sock_out.sin_family = PF_INET; @@ -159,7 +180,9 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb) sock.sin_port = htons(ctdb->address.port); sock.sin_family = PF_INET; - inet_pton(AF_INET, ctdb->address.address, &sock.sin_addr); + if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock.sin_addr) != 0) { + return -1; + } ctcp->listen_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (ctcp->listen_fd == -1) { |