apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r552149 - in /apr/apr/branches/1.2.x: CHANGES test/testsockets.c
Date Sat, 30 Jun 2007 14:01:49 GMT
Author: davi
Date: Sat Jun 30 07:01:49 2007
New Revision: 552149

URL: http://svn.apache.org/viewvc?view=rev&rev=552149
Log:
Backport 552147 from trunk with more failure checks:

Split the sendto_receivefrom test into two tests, one for IPv6 and one
for IPv4, and allow the tests to fail. Previously the test would fail
or succeed depending on the host IPv6 connectivity (non-localhost IPv6
address) and resolver bugs (AI_ADDRCONFIG flag), which would cause the
test to core dump.

Modified:
    apr/apr/branches/1.2.x/CHANGES
    apr/apr/branches/1.2.x/test/testsockets.c

Modified: apr/apr/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/CHANGES?view=diff&rev=552149&r1=552148&r2=552149
==============================================================================
--- apr/apr/branches/1.2.x/CHANGES (original)
+++ apr/apr/branches/1.2.x/CHANGES Sat Jun 30 07:01:49 2007
@@ -1,5 +1,8 @@
 Changes for APR 1.2.10
 
+  *) Allow IPv6 connectivity test to fail, avoiding a potentially fatal
+     error.  [Davi Arnaut]
+
   *) The MinGW Windows headers effectively redefines WINADVAPI from
      __stdcall to empty which results in a link failure when wincrypt.h
      is placed after an include to apr_private.h.

Modified: apr/apr/branches/1.2.x/test/testsockets.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.2.x/test/testsockets.c?view=diff&rev=552149&r1=552148&r2=552149
==============================================================================
--- apr/apr/branches/1.2.x/test/testsockets.c (original)
+++ apr/apr/branches/1.2.x/test/testsockets.c Sat Jun 30 07:01:49 2007
@@ -103,7 +103,7 @@
 #endif
 }
 
-static void sendto_receivefrom(abts_case *tc, void *data)
+static void sendto_receivefrom_helper(abts_case *tc, const char *addr, int family)
 {
     apr_status_t rv;
     apr_socket_t *sock = NULL;
@@ -115,28 +115,19 @@
     apr_sockaddr_t *from;
     apr_sockaddr_t *to;
     apr_size_t len = 30;
-    int family;
-    const char *addr;
 
-#if APR_HAVE_IPV6
-    family = APR_INET6;
-    addr = "::1";
     rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p);
-    if (V6_NOT_ENABLED(rv)) {
-#endif
-        family = APR_INET;
-        addr = "127.0.0.1";
-        rv = apr_socket_create(&sock, family, SOCK_DGRAM, 0, p);
-#if APR_HAVE_IPV6
-    } 
-#endif
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    if (rv != APR_SUCCESS)
+        return;
     rv = apr_socket_create(&sock2, family, SOCK_DGRAM, 0, p);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    if (rv != APR_SUCCESS)
+        return;
 
-    rv = apr_sockaddr_info_get(&to, addr, APR_UNSPEC, 7772, 0, p);
+    rv = apr_sockaddr_info_get(&to, addr, family, 7772, 0, p);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
-    rv = apr_sockaddr_info_get(&from, addr, APR_UNSPEC, 7771, 0, p);
+    rv = apr_sockaddr_info_get(&from, addr, family, 7771, 0, p);
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
 
     rv = apr_socket_opt_set(sock, APR_SO_REUSEADDR, 1);
@@ -145,9 +136,14 @@
     APR_ASSERT_SUCCESS(tc, "Could not set REUSEADDR on socket2", rv);
 
     rv = apr_socket_bind(sock, to);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    APR_ASSERT_SUCCESS(tc, "Could not bind socket", rv);
+    if (rv != APR_SUCCESS)
+        return;
+
     rv = apr_socket_bind(sock2, from);
-    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    APR_ASSERT_SUCCESS(tc, "Could not bind second socket", rv);
+    if (rv != APR_SUCCESS)
+        return;
 
     len = STRLEN;
     rv = apr_socket_sendto(sock2, to, 0, sendbuf, &len);
@@ -167,6 +163,14 @@
 
     apr_socket_close(sock);
     apr_socket_close(sock2);
+}
+
+static void sendto_receivefrom(abts_case *tc, void *data)
+{
+#if APR_HAVE_IPV6
+    sendto_receivefrom_helper(tc, "::1", APR_INET6);
+#endif
+    sendto_receivefrom_helper(tc, "127.0.0.1", APR_INET);
 }
 
 static void socket_userdata(abts_case *tc, void *data)



Mime
View raw message