mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
Make the 'areschannel' get created in the curl_easy_init() and re-use that
same channel during the whole curl handle's life until curl_easy_cleanup().
This commit is contained in:
parent
f516734941
commit
ccdaa0b51f
14
lib/hostip.c
14
lib/hostip.c
@ -469,7 +469,6 @@ CURLcode Curl_is_resolved(struct connectdata *conn,
|
|||||||
|
|
||||||
if(conn->async.done) {
|
if(conn->async.done) {
|
||||||
/* we're done, kill the ares handle */
|
/* we're done, kill the ares handle */
|
||||||
ares_destroy(data->state.areschannel);
|
|
||||||
if(!conn->async.dns)
|
if(!conn->async.dns)
|
||||||
return CURLE_COULDNT_RESOLVE_HOST;
|
return CURLE_COULDNT_RESOLVE_HOST;
|
||||||
*dns = conn->async.dns;
|
*dns = conn->async.dns;
|
||||||
@ -536,9 +535,6 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn,
|
|||||||
/* Operation complete, if the lookup was successful we now have the entry
|
/* Operation complete, if the lookup was successful we now have the entry
|
||||||
in the cache. */
|
in the cache. */
|
||||||
|
|
||||||
/* this destroys the channel and we cannot use it anymore after this */
|
|
||||||
ares_destroy(data->state.areschannel);
|
|
||||||
|
|
||||||
if(entry)
|
if(entry)
|
||||||
*entry = conn->async.dns;
|
*entry = conn->async.dns;
|
||||||
|
|
||||||
@ -613,17 +609,11 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
|||||||
int port,
|
int port,
|
||||||
int *waitp)
|
int *waitp)
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
char *bufp;
|
char *bufp;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
|
||||||
rc = ares_init(&data->state.areschannel);
|
|
||||||
|
|
||||||
*waitp = FALSE;
|
*waitp = FALSE;
|
||||||
|
|
||||||
if(!rc) {
|
|
||||||
/* only if success */
|
|
||||||
|
|
||||||
bufp = strdup(hostname);
|
bufp = strdup(hostname);
|
||||||
|
|
||||||
if(bufp) {
|
if(bufp) {
|
||||||
@ -634,15 +624,13 @@ static Curl_addrinfo *my_getaddrinfo(struct connectdata *conn,
|
|||||||
conn->async.status = 0; /* clear */
|
conn->async.status = 0; /* clear */
|
||||||
conn->async.dns = NULL; /* clear */
|
conn->async.dns = NULL; /* clear */
|
||||||
|
|
||||||
|
/* areschannel is already setup in the Curl_open() function */
|
||||||
ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
|
ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
|
||||||
host_callback, conn);
|
host_callback, conn);
|
||||||
|
|
||||||
|
|
||||||
*waitp = TRUE; /* please wait for the response */
|
*waitp = TRUE; /* please wait for the response */
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ares_destroy(data->state.areschannel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL; /* no struct yet */
|
return NULL; /* no struct yet */
|
||||||
|
|
||||||
|
15
lib/url.c
15
lib/url.c
@ -233,6 +233,11 @@ CURLcode Curl_close(struct SessionHandle *data)
|
|||||||
|
|
||||||
Curl_digest_cleanup(data);
|
Curl_digest_cleanup(data);
|
||||||
|
|
||||||
|
#ifdef USE_ARES
|
||||||
|
/* this destroys the channel and we cannot use it anymore after this */
|
||||||
|
ares_destroy(data->state.areschannel);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* No longer a dirty share, if it exists */
|
/* No longer a dirty share, if it exists */
|
||||||
if (data->share)
|
if (data->share)
|
||||||
data->share->dirty--;
|
data->share->dirty--;
|
||||||
@ -253,6 +258,15 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
|
|
||||||
memset(data, 0, sizeof(struct SessionHandle));
|
memset(data, 0, sizeof(struct SessionHandle));
|
||||||
|
|
||||||
|
#ifdef USE_ARES
|
||||||
|
if(ARES_SUCCESS != ares_init(&data->state.areschannel)) {
|
||||||
|
free(data);
|
||||||
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
|
/* make sure that all other returns from this function should destroy the
|
||||||
|
ares channel before returning error! */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We do some initial setup here, all those fields that can't be just 0 */
|
/* We do some initial setup here, all those fields that can't be just 0 */
|
||||||
|
|
||||||
data->state.headerbuff=(char*)malloc(HEADERSIZE);
|
data->state.headerbuff=(char*)malloc(HEADERSIZE);
|
||||||
@ -319,7 +333,6 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE;
|
data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
memset(data->state.connects, 0,
|
memset(data->state.connects, 0,
|
||||||
sizeof(struct connectdata *)*data->state.numconnects);
|
sizeof(struct connectdata *)*data->state.numconnects);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user