mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:41:40 +03:00
async-threaded resolver: use ref counter
Allocate the data shared between a transfer and an aync resolver thread
separately and use a reference counter to determine its release.
Change `Curl_thread_destroy()` to clear the thread handle, so that the
thread is considered "gone" and we do not try to join (and fail to)
afterwards.
Retake of the revert in fb15a986c0
Closes #16916
This commit is contained in:
parent
01e76702ac
commit
9b6148e9d9
8 changed files with 145 additions and 106 deletions
|
|
@ -82,11 +82,12 @@ err:
|
|||
return curl_thread_t_null;
|
||||
}
|
||||
|
||||
void Curl_thread_destroy(curl_thread_t hnd)
|
||||
void Curl_thread_destroy(curl_thread_t *hnd)
|
||||
{
|
||||
if(hnd != curl_thread_t_null) {
|
||||
pthread_detach(*hnd);
|
||||
free(hnd);
|
||||
if(*hnd != curl_thread_t_null) {
|
||||
pthread_detach(**hnd);
|
||||
free(*hnd);
|
||||
*hnd = curl_thread_t_null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,10 +139,12 @@ curl_thread_t Curl_thread_create(
|
|||
return t;
|
||||
}
|
||||
|
||||
void Curl_thread_destroy(curl_thread_t hnd)
|
||||
void Curl_thread_destroy(curl_thread_t *hnd)
|
||||
{
|
||||
if(hnd != curl_thread_t_null)
|
||||
CloseHandle(hnd);
|
||||
if(*hnd != curl_thread_t_null) {
|
||||
CloseHandle(*hnd);
|
||||
*hnd = curl_thread_t_null;
|
||||
}
|
||||
}
|
||||
|
||||
int Curl_thread_join(curl_thread_t *hnd)
|
||||
|
|
@ -153,9 +156,7 @@ int Curl_thread_join(curl_thread_t *hnd)
|
|||
int ret = (WaitForSingleObjectEx(*hnd, INFINITE, FALSE) == WAIT_OBJECT_0);
|
||||
#endif
|
||||
|
||||
Curl_thread_destroy(*hnd);
|
||||
|
||||
*hnd = curl_thread_t_null;
|
||||
Curl_thread_destroy(hnd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue