aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-12-05 23:39:41 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-12-05 23:39:41 +0100
commit2271b60b71c4e6d3337ddde0fae81ad6bb6fe2c3 (patch)
tree6983b0e9676310dd5981251741317d4b746d0e39
parentc2bfe60086078f1dc079bdcc989bf03bd6b2ee22 (diff)
Curl_wait_for_resolv: correct timeout
When looping in this function and checking for the timeout being expired, it was not updating the reference time when calculating the timediff since previous round which made it think each subsequent loop to have taken longer than it actually did. I also modified the function to use the generic Curl_timeleft() function instead of the custom logic. Bug: http://curl.haxx.se/bug/view.cgi?id=3112579
-rw-r--r--lib/hostares.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/hostares.c b/lib/hostares.c
index e31a677da..97cb27ab9 100644
--- a/lib/hostares.c
+++ b/lib/hostares.c
@@ -224,13 +224,8 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
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 */
- if(conn->data->set.connecttimeout)
- timeout = conn->data->set.connecttimeout;
- else if(conn->data->set.timeout)
- timeout = conn->data->set.timeout;
- else
+ timeout = Curl_timeleft(conn, &now, TRUE);
+ if(!timeout)
timeout = CURL_TIMEOUT_RESOLVE * 1000; /* default name resolve timeout */
/* Wait for the name resolve query to complete. */
@@ -265,8 +260,10 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
timeout = -1; /* trigger the cancel below */
}
else {
- timediff = Curl_tvdiff(Curl_tvnow(), now); /* spent time */
+ struct timeval now2 = Curl_tvnow();
+ timediff = Curl_tvdiff(now2, now); /* spent time */
timeout -= timediff?timediff:1; /* always deduct at least 1 */
+ now = now2; /* for next loop */
}
if(timeout < 0) {
/* our timeout, so we cancel the ares operation */