Backport of r30004 to 1.4.x.
Fix the client-side problem described in issue #2382
git-svn-id: https://svn.apache.org/repos/asf/subversion/branches/1.4.x-r30004@870108 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/subversion/libsvn_ra_svn/client.c b/subversion/libsvn_ra_svn/client.c
index ca11219..64a2e77 100644
--- a/subversion/libsvn_ra_svn/client.c
+++ b/subversion/libsvn_ra_svn/client.c
@@ -126,19 +126,28 @@
if (status)
return svn_error_createf(status, NULL, _("Unknown hostname '%s'"),
hostname);
-
- /* Create the socket. */
+ /* Iterate through the returned list of addresses attempting to
+ * connect to each in turn. */
+ do
+ {
+ /* Create the socket. */
#ifdef MAX_SECS_TO_LINGER
- /* ### old APR interface */
- status = apr_socket_create(sock, sa->family, SOCK_STREAM, pool);
+ /* ### old APR interface */
+ status = apr_socket_create(sock, sa->family, SOCK_STREAM, pool);
#else
- status = apr_socket_create(sock, sa->family, SOCK_STREAM, APR_PROTO_TCP,
- pool);
+ status = apr_socket_create(sock, sa->family, SOCK_STREAM, APR_PROTO_TCP,
+ pool);
#endif
- if (status)
- return svn_error_wrap_apr(status, _("Can't create socket"));
-
- status = apr_socket_connect(*sock, sa);
+ if (status == APR_SUCCESS)
+ {
+ status = apr_socket_connect(*sock, sa);
+ if (status != APR_SUCCESS)
+ apr_socket_close(*sock);
+ }
+ sa = sa->next;
+ }
+ while (status != APR_SUCCESS && sa);
+
if (status)
return svn_error_wrap_apr(status, _("Can't connect to host '%s'"),
hostname);