]> granicus.if.org Git - libevent/commitdiff
Windows *does* have getservbyname, no matter what autoconf says.
authorNick Mathewson <nickm@torproject.org>
Tue, 17 Nov 2009 02:38:19 +0000 (02:38 +0000)
committerNick Mathewson <nickm@torproject.org>
Tue, 17 Nov 2009 02:38:19 +0000 (02:38 +0000)
TODO: figure out why autoconf is confused about this.

svn:r1538

configure.in
evutil.c
test/regress_dns.c

index c8913485c0407be7edf6f926cd150dcb13090937..e2df3825a4288cddc0edd07bef9d5cd9c35f6999 100644 (file)
@@ -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.
index b67ee73ca1d516383a85ab4936cb78aa3013ea91..73ae895c6230e231b76fe4cd35b56310e7892216 100644 (file)
--- 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) {
index b7059c0524e3623295b7dbe6638fc7a558b4ef79..d3c0d0e306c61d5e3f6f15275234eb27a41b0505 100644 (file)
@@ -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));