mirror of
https://github.com/curl/curl.git
synced 2026-08-24 16:23:34 +03:00
asyn-thread: use GetAddrInfoExW on >= Windows 8
For doing async DNS resolution instead of starting a thread for each request. Fixes #12481 Closes #12482
This commit is contained in:
parent
a719be81e9
commit
a6bbc87f9e
3 changed files with 276 additions and 1 deletions
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
LARGE_INTEGER Curl_freq;
|
||||
bool Curl_isVistaOrGreater;
|
||||
bool Curl_isWindows8OrGreater;
|
||||
|
||||
/* Handle of iphlpapp.dll */
|
||||
static HMODULE s_hIpHlpApiDll = NULL;
|
||||
|
|
@ -45,9 +46,19 @@ static HMODULE s_hIpHlpApiDll = NULL;
|
|||
/* Pointer to the if_nametoindex function */
|
||||
IF_NAMETOINDEX_FN Curl_if_nametoindex = NULL;
|
||||
|
||||
void(WSAAPI *Curl_FreeAddrInfoExW)(ADDRINFOEXW_ *pAddrInfoEx) = NULL;
|
||||
int(WSAAPI *Curl_GetAddrInfoExCancel)(LPHANDLE lpHandle) = NULL;
|
||||
int(WSAAPI *Curl_GetAddrInfoExW)(PCWSTR pName, PCWSTR pServiceName,
|
||||
DWORD dwNameSpace, LPGUID lpNspId, const ADDRINFOEXW_ *hints,
|
||||
ADDRINFOEXW_ **ppResult, struct timeval *timeout, LPOVERLAPPED lpOverlapped,
|
||||
LOOKUP_COMPLETION lpCompletionRoutine, LPHANDLE lpHandle) = NULL;
|
||||
|
||||
/* Curl_win32_init() performs win32 global initialization */
|
||||
CURLcode Curl_win32_init(long flags)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
HANDLE ws2_32Dll;
|
||||
#endif
|
||||
/* CURL_GLOBAL_WIN32 controls the *optional* part of the initialization which
|
||||
is just for Winsock at the moment. Any required win32 initialization
|
||||
should take place after this block. */
|
||||
|
|
@ -104,6 +115,18 @@ CURLcode Curl_win32_init(long flags)
|
|||
Curl_if_nametoindex = pIfNameToIndex;
|
||||
}
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
ws2_32Dll = GetModuleHandleA("ws2_32");
|
||||
if(ws2_32Dll) {
|
||||
*(FARPROC*)&Curl_FreeAddrInfoExW = GetProcAddress(ws2_32Dll,
|
||||
"FreeAddrInfoExW");
|
||||
*(FARPROC*)&Curl_GetAddrInfoExCancel = GetProcAddress(ws2_32Dll,
|
||||
"GetAddrInfoExCancel");
|
||||
*(FARPROC*)&Curl_GetAddrInfoExW = GetProcAddress(ws2_32Dll,
|
||||
"GetAddrInfoExW");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* curlx_verify_windows_version must be called during init at least once
|
||||
because it has its own initialization routine. */
|
||||
if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT,
|
||||
|
|
@ -113,6 +136,13 @@ CURLcode Curl_win32_init(long flags)
|
|||
else
|
||||
Curl_isVistaOrGreater = FALSE;
|
||||
|
||||
if(curlx_verify_windows_version(6, 2, 0, PLATFORM_WINNT,
|
||||
VERSION_GREATER_THAN_EQUAL)) {
|
||||
Curl_isWindows8OrGreater = TRUE;
|
||||
}
|
||||
else
|
||||
Curl_isWindows8OrGreater = FALSE;
|
||||
|
||||
QueryPerformanceFrequency(&Curl_freq);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
|
@ -120,6 +150,9 @@ CURLcode Curl_win32_init(long flags)
|
|||
/* Curl_win32_cleanup() is the opposite of Curl_win32_init() */
|
||||
void Curl_win32_cleanup(long init_flags)
|
||||
{
|
||||
Curl_FreeAddrInfoExW = NULL;
|
||||
Curl_GetAddrInfoExCancel = NULL;
|
||||
Curl_GetAddrInfoExW = NULL;
|
||||
if(s_hIpHlpApiDll) {
|
||||
FreeLibrary(s_hIpHlpApiDll);
|
||||
s_hIpHlpApiDll = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue