diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-03-16 09:21:24 +1100 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2009-03-16 09:21:24 +1100 |
commit | 869941c0cf6223107c83f2312729a542374e15c6 (patch) | |
tree | b1777f496ed44c09edffd4cfb4d50fb54922c4d6 /ctdb/tcp | |
parent | 4088e0aceb6b31f5de6b3d10a63ae4cc22c3e867 (diff) | |
download | samba-869941c0cf6223107c83f2312729a542374e15c6.tar.gz samba-869941c0cf6223107c83f2312729a542374e15c6.tar.xz samba-869941c0cf6223107c83f2312729a542374e15c6.zip |
From C Cowan, AIX needs to set sockaddr.sa_len to a consistent value for
the address type used or the connect() call will fail.
(This used to be ctdb commit d416c0e1e57a42f7ab52de903dbd8b5e111decfe)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r-- | ctdb/tcp/tcp_connect.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c index 8efb597443..ac443d1f8e 100644 --- a/ctdb/tcp/tcp_connect.c +++ b/ctdb/tcp/tcp_connect.c @@ -129,6 +129,7 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, struct ctdb_context *ctdb = node->ctdb; ctdb_sock_addr sock_in; int sockin_size; + int sockout_size; ctdb_sock_addr sock_out; ctdb_tcp_stop_connection(node); @@ -167,12 +168,20 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, if (ctdb_tcp_get_address(ctdb, ctdb->address.address, &sock_in) != 0) { return; } + + /* AIX libs check to see if the socket address and length + arguments are consistent with each other on calls like + connect(). Can not get by with just sizeof(sock_in), + need sizeof(sock_in.ip). + */ switch (sock_in.sa.sa_family) { case AF_INET: sockin_size = sizeof(sock_in.ip); + sockout_size = sizeof(sock_out.ip); break; case AF_INET6: sockin_size = sizeof(sock_in.ip6); + sockout_size = sizeof(sock_out.ip6); break; default: DEBUG(DEBUG_ERR, (__location__ " unknown family %u\n", @@ -181,10 +190,11 @@ void ctdb_tcp_node_connect(struct event_context *ev, struct timed_event *te, } #ifdef HAVE_SOCK_SIN_LEN sock_in.ip.sin_len = sockin_size; + sock_out.ip.sin_len = sockout_size; #endif bind(tnode->fd, (struct sockaddr *)&sock_in, sockin_size); - if (connect(tnode->fd, (struct sockaddr *)&sock_out, sizeof(sock_out)) != 0 && + if (connect(tnode->fd, (struct sockaddr *)&sock_out, sockout_size) != 0 && errno != EINPROGRESS) { ctdb_tcp_stop_connection(node); tnode->connect_te = event_add_timed(ctdb->ev, tnode, |