Re: Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::')
От | Tatsuo Ishii |
---|---|
Тема | Re: Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::') |
Дата | |
Msg-id | 20151026.095403.804552198762060224.t-ishii@sraoss.co.jp обсуждение исходный текст |
Ответ на | Re: Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::') (Noah Misch <noah@leadboat.com>) |
Ответы |
Re: Re: [BUGS] BUG #13611: test_postmaster_connection
failed (Windows, listen_addresses = '0.0.0.0' or '::')
|
Список | pgsql-hackers |
> As I stated upthread, PQping("host='0.0.0.0'") is _not portable_. It works on > GNU/Linux, which I used for that demo. It fails on OpenBSD and Windows. > >> I'd be inclined to suggest fixing it like this: >> >> /* If postmaster is listening on "*", use localhost */ >> - if (strcmp(host_str, "*") == 0) >> + if (strcmp(host_str, "*") == 0 || >> + strcmp(host_str, "0.0.0.0") == 0 || >> + strcmp(host_str, "::") == 0) >> strcpy(host_str, "localhost"); >> >> which covers the cases we document as supported. > > On RHEL 5 and some other "active adult" systems, "localhost" does not reach a > listen_addresses='::' server. IPv6 is available, but "localhost" resolves to > 127.0.0.1 only. > > The latest systems resolve "localhost" to both 127.0.0.1 and ::1, in which > case PQping("host='localhost'") will attempt both addresses in an unspecified > order. Given a postmaster with listen_addresses='0.0.0.0', contacting ::1 > first will fail (fine) or reach a different postmaster (not fine). > > Kondo's design is correct. So more proper fix looks like this? diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index dacdfef..23d5a3c 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -646,9 +646,11 @@ test_postmaster_connection(pgpid_t pm_pid, bool do_checkpoint) return PQPING_NO_ATTEMPT; } - /* If postmaster is listening on "*", use localhost */ - if (strcmp(host_str, "*") == 0) - strcpy(host_str, "localhost"); + /* If postmaster is listening on "*", "0.0.0.0" or "::", use 127.0.0.1 */ + if (strcmp(host_str, "*") == 0 || + strcmp(host_str, "0.0.0.0") == 0 || + strcmp(host_str, "::") == 0) + strcpy(host_str, "127.0.0.1"); /* * We need toset connect_timeout otherwise on Windows Best regards, -- Tatsuo Ishii SRA OSS, Inc. Japan English: http://www.sraoss.co.jp/index_en.php Japanese:http://www.sraoss.co.jp
В списке pgsql-hackers по дате отправления: