improve easy interface resolving timeout handling in c-ares enabled builds

This commit is contained in:
Yang Tse 2008-04-29 04:18:02 +00:00
Родитель ab71654078
Коммит 1eebb90030
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -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
* 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 socks[ARES_GETSOCK_MAXNUM];
struct pollfd pfd[ARES_GETSOCK_MAXNUM];
int m;
int i;
int num;
int num = 0;
bitmask = ares_getsock(data->state.areschannel, socks, ARES_GETSOCK_MAXNUM);
for(i=0; i < ARES_GETSOCK_MAXNUM; i++) {
pfd[i].events = 0;
m=0;
pfd[i].revents = 0;
if(ARES_GETSOCK_READABLE(bitmask, i)) {
pfd[i].fd = socks[i];
pfd[i].events |= POLLRDNORM|POLLIN;
m=1;
}
if(ARES_GETSOCK_WRITABLE(bitmask, i)) {
pfd[i].fd = socks[i];
pfd[i].events |= POLLWRNORM|POLLOUT;
m=1;
}
pfd[i].revents=0;
if(!m)
if(pfd[i].events != 0)
num++;
else
break;
}
num = i;
if(num)
nfds = Curl_poll(pfd, num, timeout_ms);
@ -233,6 +230,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
CURLcode rc=CURLE_OK;
struct SessionHandle *data = conn->data;
long timeout;
struct timeval now = Curl_tvnow();
/* now, see if there's a connect timeout or a regular timeout to
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. */
while(1) {
struct timeval *tvp, tv, store;
struct timeval now = Curl_tvnow();
long timediff;
int itimeout;
store.tv_sec = (int)timeout/1000;
store.tv_usec = (timeout%1000)*1000;
itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout;
store.tv_sec = itimeout/1000;
store.tv_usec = (itimeout%1000)*1000;
tvp = ares_timeout(data->state.areschannel, &store, &tv);