summaryrefslogtreecommitdiff
path: root/lib/hostasyn.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-12-27 09:55:13 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-12-27 10:01:44 +0100
commitb6a3e2be8e1bbb183597399c0dcdaa67022b958e (patch)
treea92f030833e3bd8d61eda610aa388bc3f87ed582 /lib/hostasyn.c
parent9f64bbd6d88a0a72614bc01ac1842b26a12f9bfd (diff)
downloadcurl-b6a3e2be8e1bbb183597399c0dcdaa67022b958e.tar.gz
c-ares: fix cancelled resolves
When built IPv6-enabled, we could do Curl_done() with one of the two resolves having returned already, so when ares_cancel() is called the resolve callback ends up doing funny things (sometimes resulting in a segfault) since it would try to actually store the previous resolve even though we're shutting down the resolve. This bug was introduced in commit 8ab137b2bc9630ce so it hasn't been included in any public release. Bug: http://curl.haxx.se/bug/view.cgi?id=3145445 Reported by: Pedro Larroy
Diffstat (limited to 'lib/hostasyn.c')
-rw-r--r--lib/hostasyn.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/hostasyn.c b/lib/hostasyn.c
index 7d35fa0e7..7a65cb1b8 100644
--- a/lib/hostasyn.c
+++ b/lib/hostasyn.c
@@ -73,6 +73,24 @@
#ifdef CURLRES_ASYNCH
/*
+ * Cancel all possibly still on-going resolves for this connection.
+ */
+void Curl_async_cancel(struct connectdata *conn)
+{
+ /* If we have a "half" response already received, we first clear that off
+ so that nothing is tempted to use it */
+ if(conn->async.temp_ai) {
+ Curl_freeaddrinfo(conn->async.temp_ai);
+ conn->async.temp_ai = NULL;
+ }
+
+ /* for ares-using, make sure all possible outstanding requests are properly
+ cancelled before we proceed */
+ ares_cancel(conn->data->state.areschannel);
+}
+
+
+/*
* Curl_addrinfo_callback() gets called by ares, gethostbyname_thread()
* or getaddrinfo_thread() when we got the name resolved (or not!).
*
@@ -82,7 +100,7 @@
*
* The storage operation locks and unlocks the DNS cache.
*/
-CURLcode Curl_addrinfo_callback(struct connectdata * conn,
+CURLcode Curl_addrinfo_callback(struct connectdata *conn,
int status,
struct Curl_addrinfo *ai)
{