Re: duplicate connection failure messages

Bruce Momjian <bruce@momjian.us>

From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@commandprompt.com>, Magnus Hagander <magnus@hagander.net>, Peter Eisentraut <peter_e@gmx.net>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2010-11-20T23:07:56Z
Lists: pgsql-hackers

Attachments

Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > I assume you are suggesting to use our inet_net_ntop() even if the
> > system has inet_ntop().
> 
> If you're going to have code to do the former, it doesn't seem to be
> worth the trouble to also have code that does the latter ...

OK, we will not call inet_ntop() at all.  I moved the CIDR part of
adt/inet_net_ntop.c into adt/inet_cidr_ntop.c, and moved the remaining
"net" part to /port/inet_net_ntop.c.

I then changed all uses of inet_ntoa to use inet_net_ntop().  While this
churn would perhaps not be warranted just to allow for better error
messages, I found pg_getaddrinfo_all() being called from
libpq::connectDBStart(), which makes it not thread-safe.  I am not
excited about backpatching it but it is a threading bug.

The output is as expected:

	$ psql -h localhost test
	psql: could not connect to server: Connection refused
	        Is the server running on host "localhost" (127.0.0.1) and accepting
	        TCP/IP connections on port 5432?
	$ psql -h 127.0.0.1 test
	psql: could not connect to server: Connection refused
	        Is the server running on host "127.0.0.1" and accepting
	        TCP/IP connections on port 5432?

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

  + It's impossible for everything to be true. +