2009-01-21 14:11:22 +00:00
|
|
|
diff -rc curl-7.19.3-orig/lib/connect.c curl-7.19.3/lib/connect.c
|
|
|
|
*** curl-7.19.3-orig/lib/connect.c 2009-01-02 23:30:50.000000000 +0100
|
|
|
|
--- curl-7.19.3/lib/connect.c 2009-01-21 15:04:08.000000000 +0100
|
2007-12-19 18:39:59 +00:00
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 115,121 ****
|
2007-12-19 18:39:59 +00:00
|
|
|
singleipconnect(struct connectdata *conn,
|
|
|
|
const Curl_addrinfo *ai, /* start connecting to this */
|
|
|
|
long timeout_ms,
|
|
|
|
! bool *connected);
|
|
|
|
|
|
|
|
/*
|
2008-04-23 10:30:09 +01:00
|
|
|
* Curl_timeleft() returns the amount of milliseconds left allowed for the
|
2009-01-21 14:11:22 +00:00
|
|
|
--- 115,122 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
singleipconnect(struct connectdata *conn,
|
|
|
|
const Curl_addrinfo *ai, /* start connecting to this */
|
|
|
|
long timeout_ms,
|
|
|
|
! bool *connected,
|
|
|
|
! bool *timed_out);
|
|
|
|
|
|
|
|
/*
|
2008-04-23 10:30:09 +01:00
|
|
|
* Curl_timeleft() returns the amount of milliseconds left allowed for the
|
2007-12-19 18:39:59 +00:00
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 541,546 ****
|
|
|
|
--- 542,548 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
{
|
|
|
|
curl_socket_t sockfd;
|
|
|
|
Curl_addrinfo *ai;
|
|
|
|
+ bool timed_out;
|
|
|
|
|
|
|
|
/* first close the failed socket */
|
|
|
|
sclose(conn->sock[sockindex]);
|
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 554,560 ****
|
2007-12-19 18:39:59 +00:00
|
|
|
ai = conn->ip_addr->ai_next;
|
|
|
|
|
2008-04-23 10:30:09 +01:00
|
|
|
while(ai) {
|
2007-12-19 18:39:59 +00:00
|
|
|
! sockfd = singleipconnect(conn, ai, 0L, connected);
|
|
|
|
if(sockfd != CURL_SOCKET_BAD) {
|
|
|
|
/* store the new socket descriptor */
|
|
|
|
conn->sock[sockindex] = sockfd;
|
2009-01-21 14:11:22 +00:00
|
|
|
--- 556,562 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
ai = conn->ip_addr->ai_next;
|
|
|
|
|
2008-04-23 10:30:09 +01:00
|
|
|
while(ai) {
|
2007-12-19 18:39:59 +00:00
|
|
|
! sockfd = singleipconnect(conn, ai, 0L, connected, &timed_out);
|
|
|
|
if(sockfd != CURL_SOCKET_BAD) {
|
|
|
|
/* store the new socket descriptor */
|
|
|
|
conn->sock[sockindex] = sockfd;
|
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 714,720 ****
|
2007-12-19 18:39:59 +00:00
|
|
|
singleipconnect(struct connectdata *conn,
|
|
|
|
const Curl_addrinfo *ai,
|
|
|
|
long timeout_ms,
|
|
|
|
! bool *connected)
|
|
|
|
{
|
2009-01-21 14:11:22 +00:00
|
|
|
struct Curl_sockaddr_ex addr;
|
2007-12-19 18:39:59 +00:00
|
|
|
char addr_buf[128];
|
2009-01-21 14:11:22 +00:00
|
|
|
--- 716,723 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
singleipconnect(struct connectdata *conn,
|
|
|
|
const Curl_addrinfo *ai,
|
|
|
|
long timeout_ms,
|
|
|
|
! bool *connected,
|
|
|
|
! bool *timed_out)
|
|
|
|
{
|
2009-01-21 14:11:22 +00:00
|
|
|
struct Curl_sockaddr_ex addr;
|
2007-12-19 18:39:59 +00:00
|
|
|
char addr_buf[128];
|
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 730,735 ****
|
|
|
|
--- 733,740 ----
|
|
|
|
struct sockaddr_in6 * const sa6 = (void *)&addr.sa_addr;
|
|
|
|
#endif
|
2007-12-19 18:39:59 +00:00
|
|
|
|
|
|
|
+ *timed_out = FALSE;
|
|
|
|
+
|
2009-01-21 14:11:22 +00:00
|
|
|
/*
|
|
|
|
* The Curl_sockaddr_ex structure is basically libcurl's external API
|
|
|
|
* curl_sockaddr structure with enough space available to directly hold
|
2007-12-19 18:39:59 +00:00
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 880,887 ****
|
2007-12-19 18:39:59 +00:00
|
|
|
infof(data, "connected\n");
|
|
|
|
return sockfd;
|
|
|
|
}
|
|
|
|
! else if(WAITCONN_TIMEOUT == rc)
|
|
|
|
infof(data, "Timeout\n");
|
|
|
|
else {
|
|
|
|
data->state.os_errno = error;
|
|
|
|
infof(data, "%s\n", Curl_strerror(conn, error));
|
2009-01-21 14:11:22 +00:00
|
|
|
--- 885,894 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
infof(data, "connected\n");
|
|
|
|
return sockfd;
|
|
|
|
}
|
|
|
|
! else if(WAITCONN_TIMEOUT == rc) {
|
|
|
|
! *timed_out = TRUE;
|
|
|
|
infof(data, "Timeout\n");
|
|
|
|
+ }
|
|
|
|
else {
|
|
|
|
data->state.os_errno = error;
|
|
|
|
infof(data, "%s\n", Curl_strerror(conn, error));
|
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 911,918 ****
|
2008-04-23 10:30:09 +01:00
|
|
|
int num_addr;
|
2007-12-19 18:39:59 +00:00
|
|
|
Curl_addrinfo *ai;
|
|
|
|
Curl_addrinfo *curr_addr;
|
|
|
|
|
|
|
|
- struct timeval after;
|
|
|
|
struct timeval before = Curl_tvnow();
|
|
|
|
|
|
|
|
/*************************************************************
|
2009-01-21 14:11:22 +00:00
|
|
|
--- 918,925 ----
|
2008-04-23 10:30:09 +01:00
|
|
|
int num_addr;
|
2007-12-19 18:39:59 +00:00
|
|
|
Curl_addrinfo *ai;
|
|
|
|
Curl_addrinfo *curr_addr;
|
|
|
|
+ bool timed_out;
|
|
|
|
|
|
|
|
struct timeval before = Curl_tvnow();
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
***************
|
2009-01-21 14:11:22 +00:00
|
|
|
*** 955,973 ****
|
2007-12-19 18:39:59 +00:00
|
|
|
curr_addr = curr_addr->ai_next, aliasindex++) {
|
|
|
|
|
|
|
|
/* start connecting to the IP curr_addr points to */
|
|
|
|
! sockfd = singleipconnect(conn, curr_addr, timeout_per_addr, connected);
|
|
|
|
|
|
|
|
if(sockfd != CURL_SOCKET_BAD)
|
|
|
|
break;
|
|
|
|
|
|
|
|
! /* get a new timeout for next attempt */
|
|
|
|
! after = Curl_tvnow();
|
|
|
|
! timeout_ms -= Curl_tvdiff(after, before);
|
|
|
|
! if(timeout_ms < 0) {
|
|
|
|
failf(data, "connect() timed out!");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
- before = after;
|
|
|
|
} /* end of connect-to-each-address loop */
|
|
|
|
|
2009-01-21 14:11:22 +00:00
|
|
|
*sockconn = sockfd; /* the socket descriptor we've connected */
|
|
|
|
--- 962,978 ----
|
2007-12-19 18:39:59 +00:00
|
|
|
curr_addr = curr_addr->ai_next, aliasindex++) {
|
|
|
|
|
|
|
|
/* start connecting to the IP curr_addr points to */
|
|
|
|
! sockfd = singleipconnect(conn, curr_addr, timeout_per_addr, connected, &timed_out);
|
|
|
|
|
|
|
|
if(sockfd != CURL_SOCKET_BAD)
|
|
|
|
break;
|
|
|
|
|
|
|
|
! /* if this is the last address and it timed out, propagate the
|
|
|
|
! timeout to the caller */
|
|
|
|
! if(!curr_addr->ai_next && timed_out) {
|
|
|
|
failf(data, "connect() timed out!");
|
|
|
|
return CURLE_OPERATION_TIMEDOUT;
|
|
|
|
}
|
|
|
|
} /* end of connect-to-each-address loop */
|
|
|
|
|
2009-01-21 14:11:22 +00:00
|
|
|
*sockconn = sockfd; /* the socket descriptor we've connected */
|