From 888007f9a4617db574b0455919b52867cc8ce64d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 17 Nov 2009 02:38:19 +0000 Subject: [PATCH] Windows *does* have getservbyname, no matter what autoconf says. TODO: figure out why autoconf is confused about this. svn:r1538 --- configure.in | 2 +- evutil.c | 2 +- test/regress_dns.c | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/configure.in b/configure.in index c8913485..e2df3825 100644 --- a/configure.in +++ b/configure.in @@ -171,7 +171,7 @@ die horribly AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue) if test x$bwin32 = xtrue; then - LIBS="$LIBS -lws2_32" + AC_SEARCH_LIBS([getservbyname],[ws2_32]) fi dnl Checks for typedefs, structures, and compiler characteristics. diff --git a/evutil.c b/evutil.c index b67ee73c..73ae895c 100644 --- a/evutil.c +++ b/evutil.c @@ -502,7 +502,7 @@ evutil_parse_servname(const char *servname, const char *protocol, n = (int) strtol(servname, &endptr, 10); if (n>=0 && n <= 65535 && servname[0] && endptr && !endptr[0]) return n; -#ifdef _EVENT_HAVE_GETSERVBYNAME +#if defined(_EVENT_HAVE_GETSERVBYNAME) || defined(WIN32) if (!(hints->ai_flags & EVUTIL_AI_NUMERICSERV)) { struct servent *ent = getservbyname(servname, protocol); if (ent) { diff --git a/test/regress_dns.c b/test/regress_dns.c index b7059c05..d3c0d0e3 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -1183,11 +1183,14 @@ test_getaddrinfo_async(void *arg) r = evdns_getaddrinfo(dns_base, "1.2.3.4", "http", &hints, gai_cb, &local_outcome); tt_int_op(r,==,0); - tt_int_op(local_outcome.err,==,0); - tt_ptr_op(local_outcome.ai,!=,NULL); - test_ai_eq(local_outcome.ai, "1.2.3.4:80", SOCK_STREAM, IPPROTO_TCP); - evutil_freeaddrinfo(local_outcome.ai); - local_outcome.ai = NULL; + if (!local_outcome.err) { + tt_ptr_op(local_outcome.ai,!=,NULL); + test_ai_eq(local_outcome.ai, "1.2.3.4:80", SOCK_STREAM, IPPROTO_TCP); + evutil_freeaddrinfo(local_outcome.ai); + local_outcome.ai = NULL; + } else { + TT_BLATHER(("Apparently we have no getservbyname.")); + } /* 1b. EVUTIL_AI_NUMERICHOST is set */ memset(&hints, 0, sizeof(hints));