diff options
Diffstat (limited to 'lib/connect.c')
-rw-r--r-- | lib/connect.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/connect.c b/lib/connect.c index 42e73360a..0250ceb45 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -679,17 +679,18 @@ UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr, connection */ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) { - curl_socklen_t len; - struct Curl_sockaddr_storage ssrem; - struct Curl_sockaddr_storage ssloc; - struct Curl_easy *data = conn->data; - if(conn->socktype == SOCK_DGRAM) /* there's no connection! */ return; +#if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME) if(!conn->bits.reuse && !conn->bits.tcp_fastopen) { + struct Curl_easy *data = conn->data; char buffer[STRERROR_LEN]; + struct Curl_sockaddr_storage ssrem; + struct Curl_sockaddr_storage ssloc; + curl_socklen_t len; +#ifdef HAVE_GETPEERNAME len = sizeof(struct Curl_sockaddr_storage); if(getpeername(sockfd, (struct sockaddr*) &ssrem, &len)) { int error = SOCKERRNO; @@ -697,7 +698,8 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) error, Curl_strerror(error, buffer, sizeof(buffer))); return; } - +#endif +#ifdef HAVE_GETSOCKNAME len = sizeof(struct Curl_sockaddr_storage); memset(&ssloc, 0, sizeof(ssloc)); if(getsockname(sockfd, (struct sockaddr*) &ssloc, &len)) { @@ -706,7 +708,8 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) error, Curl_strerror(error, buffer, sizeof(buffer))); return; } - +#endif +#ifdef HAVE_GETPEERNAME if(!getaddressinfo((struct sockaddr*)&ssrem, conn->primary_ip, &conn->primary_port)) { failf(data, "ssrem inet_ntop() failed with errno %d: %s", @@ -714,15 +717,17 @@ void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd) return; } memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN); - +#endif +#ifdef HAVE_GETSOCKNAME if(!getaddressinfo((struct sockaddr*)&ssloc, conn->local_ip, &conn->local_port)) { failf(data, "ssloc inet_ntop() failed with errno %d: %s", errno, Curl_strerror(errno, buffer, sizeof(buffer))); return; } - +#endif } +#endif /* persist connection info in session handle */ Curl_persistconninfo(conn); |