diff options
author | Daniel Stenberg <daniel@haxx.se> | 2011-04-27 13:07:49 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-04-28 15:25:03 +0200 |
commit | c33aee1667bd037068674bd354ffd0feb1d13de1 (patch) | |
tree | 970be07d5f41872a5eff0c1b37e45ac902d042ab /m4 | |
parent | 3b1b26578f7b21e2bfca1d1738aa77a44e11e111 (diff) |
treaded-resolver: better error messages
Now use gai_strerror() to get proper error messages when getaddrinfo()
has failed. Detect the function in configure.
Code based on work and suggestions by Jeff Pohlmeyer and Guenter Knauf
Diffstat (limited to 'm4')
-rw-r--r-- | m4/curl-functions.m4 | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 6067abf96..ec57b5423 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -5,7 +5,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -2314,6 +2314,99 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYADDR], [ fi ]) +dnl CURL_CHECK_FUNC_GAI_STRERROR +dnl ------------------------------------------------- +dnl Verify if gai_strerror is available, prototyped, +dnl and can be compiled. If all of these are true, +dnl and usage has not been previously disallowed with +dnl shell variable curl_disallow_gai_strerror, then +dnl HAVE_GAI_STRERROR will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_GAI_STRERROR], [ + AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl + AC_REQUIRE([CURL_INCLUDES_NETDB])dnl + # + tst_links_gai_strerror="unknown" + tst_proto_gai_strerror="unknown" + tst_compi_gai_strerror="unknown" + tst_allow_gai_strerror="unknown" + # + AC_MSG_CHECKING([if gai_strerror can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + $curl_includes_netdb + ]],[[ + if(0 != gai_strerror(0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_gai_strerror="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_gai_strerror="no" + ]) + # + if test "$tst_links_gai_strerror" = "yes"; then + AC_MSG_CHECKING([if gai_strerror is prototyped]) + AC_EGREP_CPP([gai_strerror],[ + $curl_includes_winsock2 + $curl_includes_netdb + ],[ + AC_MSG_RESULT([yes]) + tst_proto_gai_strerror="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_gai_strerror="no" + ]) + fi + # + if test "$tst_proto_gai_strerror" = "yes"; then + AC_MSG_CHECKING([if gai_strerror is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + $curl_includes_netdb + ]],[[ + if(0 != gai_strerror(0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_gai_strerror="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_gai_strerror="no" + ]) + fi + # + if test "$tst_compi_gai_strerror" = "yes"; then + AC_MSG_CHECKING([if gai_strerror usage allowed]) + if test "x$curl_disallow_gai_strerror" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_gai_strerror="yes" + else + AC_MSG_RESULT([no]) + tst_allow_gai_strerror="no" + fi + fi + # + AC_MSG_CHECKING([if gai_strerror might be used]) + if test "$tst_links_gai_strerror" = "yes" && + test "$tst_proto_gai_strerror" = "yes" && + test "$tst_compi_gai_strerror" = "yes" && + test "$tst_allow_gai_strerror" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_GAI_STRERROR, 1, + [Define to 1 if you have the gai_strerror function.]) + ac_cv_func_gai_strerror="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_gai_strerror="no" + fi +]) + dnl CURL_CHECK_FUNC_GETHOSTBYADDR_R dnl ------------------------------------------------- |