Hans Leidekker : iphlpapi: Only call res_init() once per process.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Apr 19 05:24:21 CDT 2007
Module: wine
Branch: master
Commit: dfebf1b91d29898731af7976fcc23ff4ac683b2d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dfebf1b91d29898731af7976fcc23ff4ac683b2d
Author: Hans Leidekker <hans at it.vu.nl>
Date: Wed Apr 18 20:39:33 2007 +0200
iphlpapi: Only call res_init() once per process.
---
dlls/dnsapi/query.c | 15 +++++++++++++--
dlls/iphlpapi/iphlpapi_main.c | 14 +++++++++++++-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/dnsapi/query.c b/dlls/dnsapi/query.c
index 38f8801..5d9d6db 100644
--- a/dlls/dnsapi/query.c
+++ b/dlls/dnsapi/query.c
@@ -65,6 +65,17 @@ static CRITICAL_SECTION resolver_cs = { &resolver_cs_debug, -1, 0, 0, 0, 0 };
#define LOCK_RESOLVER() do { EnterCriticalSection( &resolver_cs ); } while (0)
#define UNLOCK_RESOLVER() do { LeaveCriticalSection( &resolver_cs ); } while (0)
+static int resolver_initialised;
+
+/* call res_init() just once because of a bug in Mac OSX 10.4 */
+static void initialise_resolver( void )
+{
+ if (!resolver_initialised)
+ {
+ res_init();
+ resolver_initialised = 1;
+ }
+}
static const char *dns_section_to_str( ns_sect section )
{
@@ -699,7 +710,7 @@ DNS_STATUS WINAPI DnsQuery_UTF8( PCSTR name, WORD type, DWORD options, PIP4_ARRA
LOCK_RESOLVER();
- res_init();
+ initialise_resolver();
_res.options |= dns_map_options( options );
if (servers && (ret = dns_set_serverlist( servers )))
@@ -817,7 +828,7 @@ DNS_STATUS WINAPI DnsQueryConfig( DNS_CONFIG_TYPE config, DWORD flag, PWSTR adap
#ifdef HAVE_RESOLV
LOCK_RESOLVER();
- res_init();
+ initialise_resolver();
ret = dns_get_serverlist( buffer, len );
UNLOCK_RESOLVER();
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index e408547..c80e1e0 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -50,6 +50,18 @@ 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 OSX 10.4 */
+static void initialise_resolver(void)
+{
+ if (!resolver_initialised)
+ {
+ res_init();
+ resolver_initialised = 1;
+ }
+}
+
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason) {
@@ -1340,7 +1352,7 @@ DWORD WINAPI GetNetworkParams(PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
if (!pOutBufLen)
return ERROR_INVALID_PARAMETER;
- res_init();
+ initialise_resolver();
size = sizeof(FIXED_INFO) + (_res.nscount > 0 ? (_res.nscount - 1) *
sizeof(IP_ADDR_STRING) : 0);
if (!pFixedInfo || *pOutBufLen < size) {
More information about the wine-cvs
mailing list