aboutsummaryrefslogtreecommitdiff
path: root/lib/multi.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2013-10-26 14:17:33 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-10-27 11:19:53 +0100
commit7d7df831981feebdbfeb21c12d6c068312a6e4b6 (patch)
tree0f9020e62bfbc3fa74b2d7a9200f03cf5fe4e1ae /lib/multi.c
parent7de4cc35f81aa6c3cdb8b377a27843bcabdaec48 (diff)
Add "Happy Eyeballs" for IPv4/IPv6.
This patch invokes two socket connect()s nearly simultaneously, and the socket that is first connected "wins" and is subsequently used for the connection. The other is terminated. There is a very slight IPv4 preference, in that if both sockets connect simultaneously IPv4 is checked first and thus will win.
Diffstat (limited to 'lib/multi.c')
-rw-r--r--lib/multi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/multi.c b/lib/multi.c
index e723a3ebf..f11ba069b 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -621,17 +621,26 @@ static int waitconnect_getsock(struct connectdata *conn,
curl_socket_t *sock,
int numsocks)
{
+ int i;
+ int s=0;
+ int rc=0;
+
if(!numsocks)
return GETSOCK_BLANK;
- sock[0] = conn->sock[FIRSTSOCKET];
+ for(i=0; i<2; i++) {
+ if(conn->tempsock[i] != CURL_SOCKET_BAD) {
+ sock[s] = conn->tempsock[i];
+ rc |= GETSOCK_WRITESOCK(s++);
+ }
+ }
/* when we've sent a CONNECT to a proxy, we should rather wait for the
socket to become readable to be able to get the response headers */
if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
return GETSOCK_READSOCK(0);
- return GETSOCK_WRITESOCK(0);
+ return rc;
}
static int domore_getsock(struct connectdata *conn,