Makefile.am: increment -version-info for 1.10.0 release
[platform/upstream/c-ares.git] / ares_library_init.c
index 1a875da..770e7c2 100644 (file)
@@ -26,6 +26,7 @@
 #ifdef USE_WINSOCK
 fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
 fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
+fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
 #endif
 
 /* library-private global vars with source visibility restricted to this file */
@@ -56,6 +57,15 @@ static int ares_win32_init(void)
       return ARES_EADDRGETNETWORKPARAMS;
     }
 
+  ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
+    GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
+  if (!ares_fpGetAdaptersAddresses)
+    {
+      /* This can happen on clients before WinXP, I don't
+         think it should be an error, unless we don't want to
+         support Windows 2000 anymore */
+    }
+
   /*
    * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
    * also known as RtlGenRandom, which is the case for Windows versions prior
@@ -91,7 +101,10 @@ int ares_library_init(int flags)
   int res;
 
   if (ares_initialized)
-    return ARES_SUCCESS;
+    {
+      ares_initialized++;
+      return ARES_SUCCESS;
+    }
   ares_initialized++;
 
   if (flags & ARES_LIB_INIT_WIN32)
@@ -112,6 +125,8 @@ void ares_library_cleanup(void)
   if (!ares_initialized)
     return;
   ares_initialized--;
+  if (ares_initialized)
+    return;
 
   if (ares_init_flags & ARES_LIB_INIT_WIN32)
     ares_win32_cleanup();