mirror of
https://github.com/curl/curl.git
synced 2026-04-11 12:01:42 +08:00
ares: handle channel being destroyed early
We are destroying the ares channel already when we shutdown resolving. Querying the pollset afterwards is still happening, especially in event based processing and needs to work in the absence of a channel. Fixes #18317 Reported-by: Natris on github Closes #18318
This commit is contained in:
parent
52775a7fb4
commit
faa2db202b
@ -280,8 +280,9 @@ void Curl_async_ares_destroy(struct Curl_easy *data)
|
||||
CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps)
|
||||
{
|
||||
struct async_ares_ctx *ares = &data->state.async.ares;
|
||||
DEBUGASSERT(ares->channel);
|
||||
return Curl_ares_pollset(data, ares->channel, ps);
|
||||
if(ares->channel)
|
||||
return Curl_ares_pollset(data, ares->channel, ps);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -91,6 +91,10 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data,
|
||||
timediff_t milli;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
DEBUGASSERT(channel);
|
||||
if(!channel)
|
||||
return CURLE_FAILED_INIT;
|
||||
|
||||
bitmap = ares_getsock(channel, (ares_socket_t *)sockets,
|
||||
CURL_ARRAYSIZE(sockets));
|
||||
for(i = 0; i < CURL_ARRAYSIZE(sockets); ++i) {
|
||||
@ -107,6 +111,8 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data,
|
||||
}
|
||||
|
||||
timeout = ares_timeout(channel, &maxtime, &timebuf);
|
||||
if(!timeout)
|
||||
timeout = &maxtime;
|
||||
milli = curlx_tvtoms(timeout);
|
||||
Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
|
||||
return result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user