summaryrefslogtreecommitdiff
path: root/network_io/unix/sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'network_io/unix/sockets.c')
-rw-r--r--network_io/unix/sockets.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index 5552460ed..93f2632b8 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -338,18 +338,18 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
#endif /* SO_ERROR */
}
- if (rc == -1 && errno != EISCONN) {
- return errno;
- }
if (memcmp(sa->ipaddr_ptr, generic_inaddr_any, sa->ipaddr_len)) {
/* A real remote address was passed in. If the unspecified
* address was used, the actual remote addr will have to be
* determined using getpeername() if required. */
- /* ### this should probably be a structure copy + fixup as per
- * _accept()'s handling of local_addr */
- sock->remote_addr = sa;
sock->remote_addr_unknown = 0;
+
+ /* Copy the address structure details in. */
+ sock->remote_addr->sa = sa->sa;
+ sock->remote_addr->salen = sa->salen;
+ /* Adjust ipaddr_ptr et al. */
+ apr_sockaddr_vars_set(sock->remote_addr, sa->family, sa->port);
}
if (sock->local_addr->port == 0) {
@@ -364,6 +364,11 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
*/
sock->local_interface_unknown = 1;
}
+
+ if (rc == -1 && errno != EISCONN) {
+ return errno;
+ }
+
#ifndef HAVE_POLL
sock->connected=1;
#endif