Use conn->raddr consistently for non-connect libpq error reporting.
authorBruce Momjian <[email protected]>
Fri, 26 Nov 2010 18:26:13 +0000 (13:26 -0500)
committerBruce Momjian <[email protected]>
Fri, 26 Nov 2010 18:26:13 +0000 (13:26 -0500)
src/interfaces/libpq/fe-connect.c

index 44a3c715307b23db12038a80302079eb45c50f79..cdf8ee4929d914531e9a498d7d315d1ab5b9d91f 100644 (file)
@@ -989,6 +989,8 @@ 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.
@@ -996,9 +998,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,
-                &conn->addr_cur->ai_addr,
-                conn->addr_cur->ai_family == AF_INET ? 32 : 128,
+       else if (inet_net_ntop(host_addr_struct->sin_family,
+                &host_addr_struct->sin_addr.s_addr,
+                host_addr_struct->sin_family == AF_INET ? 32 : 128,
                 host_addr, sizeof(host_addr)) == NULL)
            strcpy(host_addr, "???");