Permalink
Browse files

ares_init: fix gethostname error detection on winsock platforms

  • Loading branch information...
1 parent cd753ff commit ef8e2ad6017a9e3a1d08b5f9e73d2bb0773cd1bb @yangtse yangtse committed Mar 22, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 ares_init.c
View
@@ -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) {

0 comments on commit ef8e2ad

Please sign in to comment.