pollita         Fri Mar 12 16:45:56 2004 EDT

  Modified files:              
    /php-src    configure.in 
  Log:
  MFB: Test getaddrinfo() for brokenness. Pretend it doesn't exist if it misbehaves.
  
http://cvs.php.net/diff.php/php-src/configure.in?r1=1.495&r2=1.496&ty=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.495 php-src/configure.in:1.496
--- php-src/configure.in:1.495  Thu Feb 12 11:26:58 2004
+++ php-src/configure.in        Fri Mar 12 16:45:55 2004
@@ -1,4 +1,4 @@
-dnl ## $Id: configure.in,v 1.495 2004/02/12 16:26:58 andi Exp $ -*- sh -*-
+dnl ## $Id: configure.in,v 1.496 2004/03/12 21:45:55 pollita Exp $ -*- sh -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -532,10 +532,45 @@
 )
 
 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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to