CVS: winex/dlls/iphlpapi iphlpapi_main.c, 1.11, 1.12

[email protected]
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/iphlpapi iphlpapi_main.c,1.11,1.12Update of /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi
In directory agravaine:/tmp/cvs-serv30752/dlls/iphlpapi

Modified Files:
	iphlpapi_main.c 
Log Message:
Only call res_init() once per process.
Original author: Hans Leidekker

Improves upon Mark's change by only calling res_init() when needed instead
of every time a process uses this DLL.


Index: iphlpapi_main.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/iphlpapi/iphlpapi_main.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- iphlpapi_main.c	27 Apr 2007 13:08:12 -0000	1.11
+++ iphlpapi_main.c	27 Apr 2007 13:08:30 -0000	1.12
@@ -50,12 +50,23 @@
 #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) {
     case DLL_PROCESS_ATTACH:
       DisableThreadLibraryCalls( hinstDLL );
-      res_init();
       break;
 
     case DLL_PROCESS_DETACH:
@@ -1341,6 +1352,7 @@
   if (!pOutBufLen)
     return ERROR_INVALID_PARAMETER;
 
+  initialise_resolver();
   size = sizeof(FIXED_INFO) + (_res.nscount > 0 ? (_res.nscount  - 1) *
    sizeof(IP_ADDR_STRING) : 0);
   if (!pFixedInfo || *pOutBufLen < size) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.