improve easy interface resolving timeout handling in c-ares enabled builds
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@@ -143,30 +143,27 @@ static int ares_waitperform(struct connectdata *conn, int timeout_ms)
|
|||||||
int bitmask;
|
int bitmask;
|
||||||
int socks[ARES_GETSOCK_MAXNUM];
|
int socks[ARES_GETSOCK_MAXNUM];
|
||||||
struct pollfd pfd[ARES_GETSOCK_MAXNUM];
|
struct pollfd pfd[ARES_GETSOCK_MAXNUM];
|
||||||
int m;
|
|
||||||
int i;
|
int i;
|
||||||
int num;
|
int num = 0;
|
||||||
|
|
||||||
bitmask = ares_getsock(data->state.areschannel, socks, ARES_GETSOCK_MAXNUM);
|
bitmask = ares_getsock(data->state.areschannel, socks, ARES_GETSOCK_MAXNUM);
|
||||||
|
|
||||||
for(i=0; i < ARES_GETSOCK_MAXNUM; i++) {
|
for(i=0; i < ARES_GETSOCK_MAXNUM; i++) {
|
||||||
pfd[i].events = 0;
|
pfd[i].events = 0;
|
||||||
m=0;
|
pfd[i].revents = 0;
|
||||||
if(ARES_GETSOCK_READABLE(bitmask, i)) {
|
if(ARES_GETSOCK_READABLE(bitmask, i)) {
|
||||||
pfd[i].fd = socks[i];
|
pfd[i].fd = socks[i];
|
||||||
pfd[i].events |= POLLRDNORM|POLLIN;
|
pfd[i].events |= POLLRDNORM|POLLIN;
|
||||||
m=1;
|
|
||||||
}
|
}
|
||||||
if(ARES_GETSOCK_WRITABLE(bitmask, i)) {
|
if(ARES_GETSOCK_WRITABLE(bitmask, i)) {
|
||||||
pfd[i].fd = socks[i];
|
pfd[i].fd = socks[i];
|
||||||
pfd[i].events |= POLLWRNORM|POLLOUT;
|
pfd[i].events |= POLLWRNORM|POLLOUT;
|
||||||
m=1;
|
|
||||||
}
|
}
|
||||||
pfd[i].revents=0;
|
if(pfd[i].events != 0)
|
||||||
if(!m)
|
num++;
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
num = i;
|
|
||||||
|
|
||||||
if(num)
|
if(num)
|
||||||
nfds = Curl_poll(pfd, num, timeout_ms);
|
nfds = Curl_poll(pfd, num, timeout_ms);
|
||||||
@@ -233,6 +230,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
CURLcode rc=CURLE_OK;
|
CURLcode rc=CURLE_OK;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
long timeout;
|
long timeout;
|
||||||
|
struct timeval now = Curl_tvnow();
|
||||||
|
|
||||||
/* now, see if there's a connect timeout or a regular timeout to
|
/* now, see if there's a connect timeout or a regular timeout to
|
||||||
use instead of the default one */
|
use instead of the default one */
|
||||||
@@ -246,11 +244,13 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
/* Wait for the name resolve query to complete. */
|
/* Wait for the name resolve query to complete. */
|
||||||
while(1) {
|
while(1) {
|
||||||
struct timeval *tvp, tv, store;
|
struct timeval *tvp, tv, store;
|
||||||
struct timeval now = Curl_tvnow();
|
|
||||||
long timediff;
|
long timediff;
|
||||||
|
int itimeout;
|
||||||
|
|
||||||
store.tv_sec = (int)timeout/1000;
|
itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
|
||||||
store.tv_usec = (timeout%1000)*1000;
|
|
||||||
|
store.tv_sec = itimeout/1000;
|
||||||
|
store.tv_usec = (itimeout%1000)*1000;
|
||||||
|
|
||||||
tvp = ares_timeout(data->state.areschannel, &store, &tv);
|
tvp = ares_timeout(data->state.areschannel, &store, &tv);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user