5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
73
73
#ifdef CURLRES_ASYNCH
76
* Cancel all possibly still on-going resolves for this connection.
78
void Curl_async_cancel(struct connectdata *conn)
80
/* If we have a "half" response already received, we first clear that off
81
so that nothing is tempted to use it */
82
if(conn->async.temp_ai) {
83
Curl_freeaddrinfo(conn->async.temp_ai);
84
conn->async.temp_ai = NULL;
76
90
* Curl_addrinfo_callback() gets called by ares, gethostbyname_thread()
77
91
* or getaddrinfo_thread() when we got the name resolved (or not!).
83
97
* The storage operation locks and unlocks the DNS cache.
85
CURLcode Curl_addrinfo_callback(struct connectdata * conn,
99
CURLcode Curl_addrinfo_callback(struct connectdata *conn,
87
101
struct Curl_addrinfo *ai)
96
110
struct SessionHandle *data = conn->data;
112
#if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */
113
Curl_addrinfo *ai_tail = ai;
115
while (ai_tail->ai_next)
116
ai_tail = ai_tail->ai_next;
118
/* Add the new results to the list of old results. */
119
ai_tail->ai_next = conn->async.temp_ai;
120
conn->async.temp_ai = ai;
122
if(--conn->async.num_pending > 0)
123
/* We are not done yet. Just return. */
126
/* make sure the temp pointer is cleared and isn't pointing to something
127
we take care of below */
128
conn->async.temp_ai = NULL;
99
131
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
111
143
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
146
#if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */
147
if(--conn->async.num_pending > 0) {
148
/* We are not done yet. Clean up and return.
149
This function will be called again. */
150
if(conn->async.temp_ai) {
151
Curl_freeaddrinfo(conn->async.temp_ai);
152
conn->async.temp_ai = NULL;
154
return CURLE_OUT_OF_MEMORY;
114
157
rc = CURLE_OUT_OF_MEMORY;
160
#if defined(ENABLE_IPV6) && defined(CURLRES_ARES) /* CURLRES_IPV6 */
163
if(--conn->async.num_pending > 0)
164
/* We are not done yet. Just return. */
167
if(conn->async.temp_ai) {
168
/* We are done, and while this latest request
169
failed, some previous results exist. */
170
struct SessionHandle *data = conn->data;
173
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
175
dns = Curl_cache_addr(data, conn->async.temp_ai,
176
conn->async.hostname,
179
/* failed to store, cleanup and return error */
180
Curl_freeaddrinfo(conn->async.temp_ai);
181
rc = CURLE_OUT_OF_MEMORY;
184
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
186
/* make sure the temp pointer is cleared and isn't pointing to
187
something we've taken care of already */
188
conn->async.temp_ai = NULL;
117
193
conn->async.dns = dns;