aboutsummaryrefslogtreecommitdiff
path: root/lib/hostip.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-04-01 08:40:36 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-04-01 08:40:36 +0000
commitad9e83a90ff756eb38099856cd80340189ae7d32 (patch)
tree8adfe77ee4efd88cef769072348e8de2eb24bcc7 /lib/hostip.c
parent6c9d96e811b7ad4d8830714011c31e5c33506829 (diff)
Dirk Manske's fix that makes sure we cancel the ares resolve when we time out
from a name resolve. Without this, we leak memory!
Diffstat (limited to 'lib/hostip.c')
-rw-r--r--lib/hostip.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/hostip.c b/lib/hostip.c
index 503231c0f..6f25de94e 100644
--- a/lib/hostip.c
+++ b/lib/hostip.c
@@ -617,7 +617,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
timeout = conn->data->set.timeout;
/* Wait for the name resolve query to complete. */
- while (timeout > 0) {
+ while (1) {
int nfds=0;
fd_set read_fds, write_fds;
struct timeval *tvp, tv, store;
@@ -641,6 +641,11 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
ares_process(data->state.areschannel, &read_fds, &write_fds);
timeout -= Curl_tvdiff(Curl_tvnow(), now)/1000; /* spent time */
+ if (timeout < 0) {
+ /* our timeout, so we cancel the ares operation */
+ ares_cancel(data->state.areschannel);
+ break;
+ }
}
/* Operation complete, if the lookup was successful we now have the entry