On Mon, Oct 26, 2015 at 09:54:03AM +0900, Tatsuo Ishii wrote:
> > Kondo's design is correct.
>
> So more proper fix looks like this?
> + /* 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");
No, PQping("host='127.0.0.1'") fails to reach a listen_addresses='::' server
on many systems. Here's what I thought Kondo was proposing:
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -649,5 +649,9 @@ test_postmaster_connection(pgpid_t pm_pid, bool do_checkpoint)
- /* If postmaster is listening on "*", use localhost */
+ /* explanation here */ if (strcmp(host_str, "*") == 0)
strcpy(host_str, "localhost");
+ else if (strcmp(host_str, "0.0.0.0") == 0)
+ strcpy(host_str, "127.0.0.1");
+ else if (strcmp(host_str, "::") == 0)
+ strcpy(host_str, "::1");