aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/hostip.h6
-rw-r--r--lib/hostthre.c15
-rw-r--r--lib/url.c7
3 files changed, 18 insertions, 10 deletions
diff --git a/lib/hostip.h b/lib/hostip.h
index 0b06bae6a..16a607abf 100644
--- a/lib/hostip.h
+++ b/lib/hostip.h
@@ -240,6 +240,12 @@ struct Curl_dns_entry *
Curl_cache_addr(struct SessionHandle *data, Curl_addrinfo *addr,
char *hostname, int port);
+/*
+ * Curl_destroy_thread_data() cleans up async resolver data.
+ * Complementary of ares_destroy.
+ */
+void Curl_destroy_thread_data(struct Curl_async *async);
+
#ifndef INADDR_NONE
#define CURL_INADDR_NONE (in_addr_t) ~0
#else
diff --git a/lib/hostthre.c b/lib/hostthre.c
index 022d8b47b..b05729404 100644
--- a/lib/hostthre.c
+++ b/lib/hostthre.c
@@ -301,10 +301,10 @@ static unsigned __stdcall getaddrinfo_thread (void *arg)
#endif
/*
- * destroy_thread_data() cleans up async resolver data.
+ * Curl_destroy_thread_data() cleans up async resolver data.
* Complementary of ares_destroy.
*/
-static void destroy_thread_data (struct Curl_async *async)
+void Curl_destroy_thread_data (struct Curl_async *async)
{
if (async->hostname)
free(async->hostname);
@@ -319,6 +319,7 @@ static void destroy_thread_data (struct Curl_async *async)
/* destroy the synchronization objects */
if (td->mutex_waiting)
CloseHandle(td->mutex_waiting);
+ td->mutex_waiting = NULL;
if (td->event_resolved)
CloseHandle(td->event_resolved);
@@ -365,7 +366,7 @@ static bool init_resolve_thread (struct connectdata *conn,
*/
td->mutex_waiting = CreateMutex(NULL, TRUE, NULL);
if (td->mutex_waiting == NULL) {
- destroy_thread_data(&conn->async);
+ Curl_destroy_thread_data(&conn->async);
SetLastError(EAGAIN);
return FALSE;
}
@@ -375,7 +376,7 @@ static bool init_resolve_thread (struct connectdata *conn,
*/
td->event_resolved = CreateEvent(NULL, TRUE, FALSE, NULL);
if (td->event_resolved == NULL) {
- destroy_thread_data(&conn->async);
+ Curl_destroy_thread_data(&conn->async);
SetLastError(EAGAIN);
return FALSE;
}
@@ -401,7 +402,7 @@ static bool init_resolve_thread (struct connectdata *conn,
if (!td->thread_hnd) {
SetLastError(errno);
TRACE(("_beginthreadex() failed; %s\n", Curl_strerror(conn,errno)));
- destroy_thread_data(&conn->async);
+ Curl_destroy_thread_data(&conn->async);
return FALSE;
}
/* This socket is only to keep Curl_resolv_fdset() and select() happy;
@@ -508,7 +509,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
rc = CURLE_OPERATION_TIMEDOUT;
}
- destroy_thread_data(&conn->async);
+ Curl_destroy_thread_data(&conn->async);
if(!conn->async.dns)
conn->bits.close = TRUE;
@@ -528,7 +529,7 @@ CURLcode Curl_is_resolved(struct connectdata *conn,
if (conn->async.done) {
/* we're done */
- destroy_thread_data(&conn->async);
+ Curl_destroy_thread_data(&conn->async);
if (!conn->async.dns) {
TRACE(("Curl_is_resolved(): CURLE_COULDNT_RESOLVE_HOST\n"));
return CURLE_COULDNT_RESOLVE_HOST;
diff --git a/lib/url.c b/lib/url.c
index e3e24a5ce..9d62f4290 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1503,11 +1503,12 @@ CURLcode Curl_disconnect(struct connectdata *conn)
Curl_safefree(conn->allocptr.cookiehost);
Curl_safefree(conn->ip_addr_str);
-#if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME) || \
- defined(USE_THREADING_GETADDRINFO)
- /* possible left-overs from the async name resolve */
+ /* possible left-overs from the async name resolvers */
+#if defined(USE_ARES)
Curl_safefree(conn->async.hostname);
Curl_safefree(conn->async.os_specific);
+#elif defined(CURLRES_THREADED)
+ Curl_destroy_thread_data(&conn->async);
#endif
Curl_free_ssl_config(&conn->ssl_config);