Colm MacCarthaigh wrote:
> On Wed, Jun 06, 2007 at 06:36:52PM -0500, William A. Rowe, Jr. wrote:
>> +1 - that sounds like a great solution. Do you want me to hold off on
>> the 1.2.10 tag for a day or two to slip this in, now that we know what
>> the case is?
>
> Nah, it's been like that for ages :-)
>
In any case, I like to have a working make test. The patch attached has been
tested on Ubuntu and Fedora.
--
Davi Arnaut
Index: apr/test/testsockets.c
===================================================================
--- apr.orig/test/testsockets.c
+++ apr/test/testsockets.c
@@ -103,7 +103,7 @@ static void udp6_socket(abts_case *tc, v
#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 @@ static void sendto_receivefrom(abts_case
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);
@@ -147,12 +138,12 @@ static void sendto_receivefrom(abts_case
rv = apr_socket_bind(sock, to);
APR_ASSERT_SUCCESS(tc, "Could not bind socket", rv);
if (rv != APR_SUCCESS)
- return;
+ return;
rv = apr_socket_bind(sock2, from);
APR_ASSERT_SUCCESS(tc, "Could not bind second socket", rv);
if (rv != APR_SUCCESS)
- return;
+ return;
len = STRLEN;
rv = apr_socket_sendto(sock2, to, 0, sendbuf, &len);
@@ -178,6 +169,14 @@ static void sendto_receivefrom(abts_case
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)
{
apr_socket_t *sock1, *sock2;