diff options
author | Bruce Momjian <bruce@momjian.us> | 2010-11-26 11:49:35 -0500 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2010-11-26 11:49:35 -0500 |
commit | ed51bd4968a903e13bdcded869a644fd0d28353c (patch) | |
tree | 0370e176827ce1a73db19dfb2ffb2c40a6ef9a24 | |
parent | 4f6deef2fb7ddc6b3c6b901db66072cf65ccaa27 (diff) | |
download | postgresql-ed51bd4968a903e13bdcded869a644fd0d28353c.tar.gz postgresql-ed51bd4968a903e13bdcded869a644fd0d28353c.zip |
Use only addr_cur when reporting connection failures in libpq.
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 6593f21d55e..8b5516759f8 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -989,8 +989,6 @@ connectFailureMessage(PGconn *conn, int errorno) { char host_addr[NI_MAXHOST]; bool display_host_addr; - struct sockaddr_in *host_addr_struct = (struct sockaddr_in *) - &conn->raddr.addr; /* * Optionally display the network address with the hostname. @@ -998,8 +996,9 @@ connectFailureMessage(PGconn *conn, int errorno) */ if (conn->pghostaddr != NULL) strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST); - else if (inet_net_ntop(conn->addr_cur->ai_family, &host_addr_struct->sin_addr, - host_addr_struct->sin_family == AF_INET ? 32 : 128, + else if (inet_net_ntop(conn->addr_cur->ai_family, + &conn->addr_cur->ai_addr, + conn->addr_cur->ai_family == AF_INET ? 32 : 128, host_addr, sizeof(host_addr)) == NULL) strcpy(host_addr, "???"); |