/* * destroy_async_data() cleans up async resolver data and thread handle. */ static void destroy_async_data (struct Curl_async *async) { if(async->os_specific) { struct thread_data *td = (struct thread_data*) async->os_specific; int done; /* * if the thread is still blocking in the resolve syscall, detach it and * let the thread do the cleanup... */ Curl_mutex_acquire(td->tsd.mtx); done = td->tsd.done; td->tsd.done = 1; Curl_mutex_release(td->tsd.mtx); if(!done) { Curl_thread_destroy(td->thread_hnd); } else { if(td->thread_hnd != curl_thread_t_null) Curl_thread_join(&td->thread_hnd); destroy_thread_sync_data(&td->tsd); free(async->os_specific); } } async->os_specific = NULL; free(async->hostname); async->hostname = NULL; }
int Curl_thread_join(curl_thread_t *hnd) { int ret = (WaitForSingleObject(*hnd, INFINITE) == WAIT_OBJECT_0); Curl_thread_destroy(*hnd); *hnd = curl_thread_t_null; return ret; }
int Curl_thread_join(curl_thread_t *hnd) { #if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ (_WIN32_WINNT < _WIN32_WINNT_VISTA) int ret = (WaitForSingleObject(*hnd, INFINITE) == WAIT_OBJECT_0); #else int ret = (WaitForSingleObjectEx(*hnd, INFINITE, FALSE) == WAIT_OBJECT_0); #endif Curl_thread_destroy(*hnd); *hnd = curl_thread_t_null; return ret; }