[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: IPv6 oddness in ra_svn

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-03-23 16:33:44 CET

Daniel Berlin wrote:
> On Tue, 2005-03-22 at 10:39 +0000, Max Bowsher wrote:
>>Why does the ipv6_supported variable exist at all in the below code?
[...]
>>Couldn't it be removed entirely with *NO* change to the functioning of the
>>code at all, like so:
>
> I can't think of a compiler that won't do this on it's own, but feel
> free :)

It's the tiny bit of extra source code that's the concern from a
maintainability point of view, more than the run-time efficiency.

Is this patch OK?

[[[
Simplify some source code.

* subversion/libsvn_ra_svn/client.c (make_connection):
* subversion/svnserve/main.c (main):
   Simplify the IPv6 detection code slightly, removing a variable.
]]]

- Julian

Simplify some source code.

* subversion/libsvn_ra_svn/client.c (make_connection):
* subversion/svnserve/main.c (main):
  Simplify the IPv6 detection code slightly, removing a variable.

Index: subversion/libsvn_ra_svn/client.c
===================================================================
--- subversion/libsvn_ra_svn/client.c (revision 13598)
+++ subversion/libsvn_ra_svn/client.c (working copy)
@@ -100,30 +100,22 @@ static svn_error_t *make_connection(cons
   apr_sockaddr_t *sa;
   apr_status_t status;
   int family = APR_INET;
-#if APR_HAVE_IPV6
- int ipv6_supported = APR_HAVE_IPV6;
-#endif
   
   /* Make sure we have IPV6 support first before giving apr_sockaddr_info_get
      APR_UNSPEC, because it may give us back an IPV6 address even if we can't
      create IPV6 sockets. */
 
 #if APR_HAVE_IPV6
- if (ipv6_supported)
- {
 #ifdef MAX_SECS_TO_LINGER
- status = apr_socket_create(sock, APR_INET6, SOCK_STREAM, pool);
+ status = apr_socket_create(sock, APR_INET6, SOCK_STREAM, pool);
 #else
- status = apr_socket_create(sock, APR_INET6, SOCK_STREAM,
- APR_PROTO_TCP, pool);
+ status = apr_socket_create(sock, APR_INET6, SOCK_STREAM,
+ APR_PROTO_TCP, pool);
 #endif
- if (status != 0)
- ipv6_supported = 0;
- else
- {
- apr_socket_close(*sock);
- family = APR_UNSPEC;
- }
+ if (status == 0)
+ {
+ apr_socket_close(*sock);
+ family = APR_UNSPEC;
     }
 #endif
 
Index: subversion/svnserve/main.c
===================================================================
--- subversion/svnserve/main.c (revision 13598)
+++ subversion/svnserve/main.c (working copy)
@@ -257,7 +257,6 @@ int main(int argc, const char *const *ar
   enum connection_handling_mode handling_mode = CONNECTION_DEFAULT;
   apr_uint16_t port = SVN_RA_SVN_PORT;
   const char *host = NULL;
- int ipv6_supported = APR_HAVE_IPV6;
   int family = APR_INET;
 
   /* Initialize the app. */
@@ -396,7 +395,7 @@ int main(int argc, const char *const *ar
     }
  
   /* Make sure we have IPV6 support first before giving apr_sockaddr_info_get
- APR_UNSPEC, becuase it may give us back an IPV6 address even if we can't
+ APR_UNSPEC, because it may give us back an IPV6 address even if we can't
      create IPV6 sockets. */
 
 #if APR_HAVE_IPV6
@@ -407,14 +406,12 @@ int main(int argc, const char *const *ar
   status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, APR_PROTO_TCP,
                              pool);
 #endif
- if (status != 0)
- ipv6_supported = 0;
- else
- apr_socket_close(sock);
+ if (status == 0)
+ {
+ apr_socket_close(sock);
+ family = APR_UNSPEC;
+ }
 #endif
-
- if (ipv6_supported)
- family = APR_UNSPEC;
   
   status = apr_sockaddr_info_get(&sa, host, family, port, 0, pool);
   if (status)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Mar 23 16:35:01 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.