ares_init: fix gethostname error detection on winsock platforms
authorYang Tse <yangsita@gmail.com>
Tue, 22 Mar 2011 12:43:34 +0000 (13:43 +0100)
committerYang Tse <yangsita@gmail.com>
Tue, 22 Mar 2011 12:43:34 +0000 (13:43 +0100)
ares_init.c

index 35e88a2b64c1e19eb9dc5868b6f01ec7936eacf6..2ce344d40642b47d7dbaa0896af0904164bc6d12 100644 (file)
@@ -1050,10 +1050,13 @@ static int init_by_defaults(ares_channel channel)
     channel->nservers = 1;
   }
 
-#ifdef ENAMETOOLONG
-#define toolong(x) (x == -1) && ((ENAMETOOLONG == errno) || (EINVAL == errno))
+#if defined(USE_WINSOCK)
+#define toolong(x) (x == -1) &&  (SOCKERRNO == WSAEFAULT)
+#elif defined(ENAMETOOLONG)
+#define toolong(x) (x == -1) && ((SOCKERRNO == ENAMETOOLONG) || \
+                                 (SOCKERRNO == EINVAL))
 #else
-#define toolong(x) (x == -1) && (EINVAL == errno)
+#define toolong(x) (x == -1) &&  (SOCKERRNO == EINVAL)
 #endif
 
   if (channel->ndomains == -1) {