From 1eebb900301940a569bc10b4b3546bfd2e839a22 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 29 Apr 2008 04:18:02 +0000 Subject: improve easy interface resolving timeout handling in c-ares enabled builds --- lib/hostares.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/hostares.c b/lib/hostares.c index fe842d1db..b6de83027 100644 --- a/lib/hostares.c +++ b/lib/hostares.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , 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; + + itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; - store.tv_sec = (int)timeout/1000; - 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); -- cgit v1.2.3