aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-09-01 16:04:39 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-09-01 16:04:39 +0200
commitce00c2ef5d5b25b045ed630c72628e8a05f51943 (patch)
treeab959a223b347d0258678f520b7608c88f4ab5ea
parent0db9140747e65ab402768670b130b0ddaa88f883 (diff)
resolve_server: simplify code
Make use of the helper function Curl_timeleft() instead of duplicating code.
-rw-r--r--lib/url.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/lib/url.c b/lib/url.c
index 99f1e7d12..8abf6e9bc 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4400,30 +4400,7 @@ static CURLcode resolve_server(struct SessionHandle *data,
bool *async)
{
CURLcode result=CURLE_OK;
- long shortest = 0; /* default to no timeout */
-
- /*************************************************************
- * Set timeout if that is being used
- *************************************************************/
- if(data->set.timeout || data->set.connecttimeout) {
-
- /* We set the timeout on the name resolving phase first, separately from
- * the download/upload part to allow a maximum time on everything. This is
- * a signal-based timeout, why it won't work and shouldn't be used in
- * multi-threaded environments. */
-
- shortest = data->set.timeout; /* default to this timeout value */
- if(shortest && data->set.connecttimeout &&
- (data->set.connecttimeout < shortest))
- /* if both are set, pick the shortest */
- shortest = data->set.connecttimeout;
- else if(!shortest)
- /* if timeout is not set, use the connect timeout */
- shortest = data->set.connecttimeout;
- /* We can expect the conn->created time to be "now", as that was just
- recently set in the beginning of this function and nothing slow
- has been done since then until now. */
- }
+ long timeout_ms = Curl_timeleft(conn, NULL, TRUE);
/*************************************************************
* Resolve the name of the server or proxy
@@ -4450,7 +4427,7 @@ static CURLcode resolve_server(struct SessionHandle *data,
/* Resolve target host right on */
rc = Curl_resolv_timeout(conn, conn->host.name, (int)conn->port,
- &hostaddr, shortest);
+ &hostaddr, timeout_ms);
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
@@ -4471,7 +4448,7 @@ static CURLcode resolve_server(struct SessionHandle *data,
/* resolve proxy */
rc = Curl_resolv_timeout(conn, conn->proxy.name, (int)conn->port,
- &hostaddr, shortest);
+ &hostaddr, timeout_ms);
if(rc == CURLRESOLV_PENDING)
*async = TRUE;