diff options
author | Sara Golemon <pollita@php.net> | 2004-03-12 21:45:55 +0000 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2004-03-12 21:45:55 +0000 |
commit | 1c7d6b229c3f994a71529a5ca20d1d4f8f5d9310 (patch) | |
tree | acf2410d7ee89f0061cf9289a70264d0dddc949c /configure.in | |
parent | e71590ef68807c7f851bcfb4e77aebf8a806e4a8 (diff) | |
download | php-git-1c7d6b229c3f994a71529a5ca20d1d4f8f5d9310.tar.gz |
MFB: Test getaddrinfo() for brokenness. Pretend it doesn't exist if it misbehaves.
Diffstat (limited to 'configure.in')
-rw-r--r-- | configure.in | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/configure.in b/configure.in index 49460892a3..b2729ea2e5 100644 --- a/configure.in +++ b/configure.in @@ -532,10 +532,45 @@ vsnprintf \ ) dnl Check for getaddrinfo, should be a better way, but... +dnl Also check for working getaddrinfo AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo, [AC_TRY_LINK([#include <netdb.h>], - [struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);], - ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no)]) + [struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);], + AC_TRY_RUN([ +#include <netdb.h> +#include <sys/types.h> +int main(void) { + struct addrinfo *ai, *pai, hints; + + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_NUMERICHOST; + + if (getaddrinfo("127.0.0.1", NULL, &hints, &ai) < 0) { + exit(1); + } + + if (ai == NULL) { + exit(1); + } + + pai = ai; + + while (pai) { + if (pai->ai_family != AF_INET) { + /* 127.0.0.1/NUMERICHOST should only resolve ONE way */ + exit(1); + } + if (pai->ai_addr->sa_family != AF_INET) { + /* 127.0.0.1/NUMERICHOST should only resolve ONE way */ + exit(1); + } + pai = pai->ai_next; + } + freeaddrinfo(ai); + exit(0); +} + ],ac_cv_func_getaddrinfo=yes, ac_cv_func_getaddrinfo=no), +ac_cv_func_getaddrinfo=no)]) if test "$ac_cv_func_getaddrinfo" = yes; then AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function]) fi |