From 22434f490a83d2a1f4c3721d95f9a7c78fd44ef1 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Mon, 8 Feb 2010 06:25:36 -0800 Subject: [PATCH] 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 011e21a6df1..7edff9ea470 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 7a35f7ce079..2410aca43cf 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(); -- 2.11.4.GIT