Module: wine Branch: master Commit: 22434f490a83d2a1f4c3721d95f9a7c78fd44ef1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=22434f490a83d2a1f4c3721d95...
Author: Dan Kegel dank@kegel.com Date: Mon Feb 8 06:25:36 2010 -0800
iphlpapi: _res is per-thread in glibc.
---
dlls/iphlpapi/iphlpapi_main.c | 9 +++------ dlls/iphlpapi/tests/iphlpapi.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index 011e21a..7edff9e 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -66,16 +66,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi); #define INADDR_NONE ~0UL #endif
-static int resolver_initialised; - /* call res_init() just once because of a bug in Mac OS X 10.4 */ +/* Call once per thread on systems that have per-thread _res. */ +/* FIXME: should do same fix in dnsapi (or use dnsapi here?) */ static void initialise_resolver(void) { - if (!resolver_initialised) - { + if ((_res.options & RES_INIT) == 0) res_init(); - resolver_initialised = 1; - } }
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) diff --git a/dlls/iphlpapi/tests/iphlpapi.c b/dlls/iphlpapi/tests/iphlpapi.c index 7a35f7c..2410aca 100644 --- a/dlls/iphlpapi/tests/iphlpapi.c +++ b/dlls/iphlpapi/tests/iphlpapi.c @@ -765,11 +765,12 @@ GetBestRoute IpReleaseAddress IpRenewAddress */ -static void testWin98Functions(void) +static DWORD CALLBACK testWin98Functions(void *p) { testGetInterfaceInfo(); testGetAdaptersInfo(); testGetNetworkParams(); + return 0; }
static void testGetPerAdapterInfo(void) @@ -885,9 +886,16 @@ START_TEST(iphlpapi)
loadIPHlpApi(); if (hLibrary) { + HANDLE thread; + testWin98OnlyFunctions(); testWinNT4Functions(); - testWin98Functions(); + + /* run testGetXXXX in two threads at once to make sure we don't crash in that case */ + thread = CreateThread(NULL, 0, testWin98Functions, NULL, 0, NULL); + testWin98Functions(NULL); + WaitForSingleObject(thread, INFINITE); + testWin2KFunctions(); test_GetAdaptersAddresses(); freeIPHlpApi();