Peter Eisentraut wrote:
> On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> > OK, I updated the code to always use cur_addr in the code --- let me
> > know if that doesn't fix it.
> 
> Now it's even more wrong:
> 
> psql: could not connect to server: Connection refused
>         Is the server running on host "localhost" (???) and accepting
>         TCP/IP connections on port 55555?
> could not connect to server: Connection refused
>         Is the server running on host "localhost" (232.106.56.8) and accepting
>         TCP/IP connections on port 55555?

Yep, even worse.  I have applied the attached patch, which gives me the
right IPv4 value.  I can't test IPv6.

I am finding the sock_addr structures confusing.

-- 
  Bruce Momjian  <br...@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 44a3c71..cdf8ee4 100644
*** /tmp/VwLJNa_fe-connect.c	Fri Nov 26 13:18:16 2010
--- src/interfaces/libpq/fe-connect.c	Fri Nov 26 13:11:12 2010
*************** connectFailureMessage(PGconn *conn, int 
*** 989,994 ****
--- 989,996 ----
  	{
  		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.
*************** connectFailureMessage(PGconn *conn, int 
*** 996,1004 ****
  		 */
  		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,
  				 host_addr, sizeof(host_addr)) == NULL)
  			strcpy(host_addr, "???");
  
--- 998,1006 ----
  		 */
  		if (conn->pghostaddr != NULL)
  			strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
! 		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, "???");
  
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to