3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/networking/curl/connect-timeout.patch
Eelco Dolstra 581af921ea * Latest OpenSSL, Curl.
svn path=/nixpkgs/branches/stdenv-updates/; revision=13817
2009-01-21 14:11:22 +00:00

157 lines
4.6 KiB
Diff

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
***************
*** 115,121 ****
singleipconnect(struct connectdata *conn,
const Curl_addrinfo *ai, /* start connecting to this */
long timeout_ms,
! bool *connected);
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
--- 115,122 ----
singleipconnect(struct connectdata *conn,
const Curl_addrinfo *ai, /* start connecting to this */
long timeout_ms,
! bool *connected,
! bool *timed_out);
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
***************
*** 541,546 ****
--- 542,548 ----
{
curl_socket_t sockfd;
Curl_addrinfo *ai;
+ bool timed_out;
/* first close the failed socket */
sclose(conn->sock[sockindex]);
***************
*** 554,560 ****
ai = conn->ip_addr->ai_next;
while(ai) {
! sockfd = singleipconnect(conn, ai, 0L, connected);
if(sockfd != CURL_SOCKET_BAD) {
/* store the new socket descriptor */
conn->sock[sockindex] = sockfd;
--- 556,562 ----
ai = conn->ip_addr->ai_next;
while(ai) {
! sockfd = singleipconnect(conn, ai, 0L, connected, &timed_out);
if(sockfd != CURL_SOCKET_BAD) {
/* store the new socket descriptor */
conn->sock[sockindex] = sockfd;
***************
*** 714,720 ****
singleipconnect(struct connectdata *conn,
const Curl_addrinfo *ai,
long timeout_ms,
! bool *connected)
{
struct Curl_sockaddr_ex addr;
char addr_buf[128];
--- 716,723 ----
singleipconnect(struct connectdata *conn,
const Curl_addrinfo *ai,
long timeout_ms,
! bool *connected,
! bool *timed_out)
{
struct Curl_sockaddr_ex addr;
char addr_buf[128];
***************
*** 730,735 ****
--- 733,740 ----
struct sockaddr_in6 * const sa6 = (void *)&addr.sa_addr;
#endif
+ *timed_out = FALSE;
+
/*
* The Curl_sockaddr_ex structure is basically libcurl's external API
* curl_sockaddr structure with enough space available to directly hold
***************
*** 880,887 ****
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));
--- 885,894 ----
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));
***************
*** 911,918 ****
int num_addr;
Curl_addrinfo *ai;
Curl_addrinfo *curr_addr;
- struct timeval after;
struct timeval before = Curl_tvnow();
/*************************************************************
--- 918,925 ----
int num_addr;
Curl_addrinfo *ai;
Curl_addrinfo *curr_addr;
+ bool timed_out;
struct timeval before = Curl_tvnow();
/*************************************************************
***************
*** 955,973 ****
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 */
*sockconn = sockfd; /* the socket descriptor we've connected */
--- 962,978 ----
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 */
*sockconn = sockfd; /* the socket descriptor we've connected */