mirror of
https://github.com/curl/curl.git
synced 2026-05-16 13:26:22 +03:00
asyn-thread: check thread_data->init in Curl_resolver_getsock
resolver may call destroy_async_data after the name is resolved and corresponding socketpair is already closed at this point. Any following call to Curl_resolver_getsock should not set the fd. Fixes #16799 Closes #16802
This commit is contained in:
parent
f68eae250b
commit
46c6ca789e
1 changed files with 9 additions and 7 deletions
|
|
@ -640,8 +640,8 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
|
|||
#endif
|
||||
|
||||
#ifdef USE_HTTPSRR_ARES
|
||||
if(data->state.async.thdata.channel) {
|
||||
ret_val = Curl_ares_getsock(data, data->state.async.thdata.channel, socks);
|
||||
if(td->init && td->channel) {
|
||||
ret_val = Curl_ares_getsock(data, td->channel, socks);
|
||||
for(socketi = 0; socketi < (MAX_SOCKSPEREASYHANDLE - 1); socketi++)
|
||||
if(!ARES_GETSOCK_READABLE(ret_val, socketi) &&
|
||||
!ARES_GETSOCK_WRITABLE(ret_val, socketi))
|
||||
|
|
@ -649,10 +649,13 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
|
|||
}
|
||||
#endif
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
/* return read fd to client for polling the DNS resolution status */
|
||||
socks[socketi] = td->tsd.sock_pair[0];
|
||||
ret_val |= GETSOCK_READSOCK(socketi);
|
||||
#else
|
||||
if(td->init) {
|
||||
/* return read fd to client for polling the DNS resolution status */
|
||||
socks[socketi] = td->tsd.sock_pair[0];
|
||||
ret_val |= GETSOCK_READSOCK(socketi);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
timediff_t milli;
|
||||
timediff_t ms = Curl_timediff(Curl_now(), td->start);
|
||||
|
|
@ -666,7 +669,6 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
|
|||
milli = 200;
|
||||
Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue