From 9557fe3fa9579302e0a23af0e912ebf9b7b3eba0 Mon Sep 17 00:00:00 2001
From: Thomas Munro <tmunro@postgresql.org>
Date: Mon, 6 May 2019 15:02:41 +1200
Subject: [PATCH] Probe only 127.0.0.1 when looking for ports on Unix.

Commit c0985099, later adjusted by commit 4ab02e81, probed 0.0.0.0
in addition to 127.0.0.1, for the benefit of Windows build farm
animals.  It isn't really useful on Unix systems, and turned out to
be a bit inconvenient to users of some corporate firewall software.
Switch back to probing just 127.0.0.1 on non-Windows systems.

Back-patch to 9.4 like the other commits.

Discussion: https://postgr.es/m/CA%2BhUKG%2B21EPwfgs4m%2BtqyRtbVqkOUvP8QQ8sWk9%2Bh55Aub1H3A%40mail.gmail.com
---
 src/test/perl/PostgresNode.pm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 76874141c5..f00e81ba74 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -1098,17 +1098,15 @@ sub get_new_node
 		# native Perl (https://stackoverflow.com/a/14388707), so we also test
 		# individual addresses.
 		#
-		# This seems like a good idea on Unixen as well, even though we don't
-		# ask the postmaster to open a TCP port on Unix.  On Non-Linux,
-		# non-Windows kernels, binding to 127.0.0.1/24 addresses other than
-		# 127.0.0.1 fails with EADDRNOTAVAIL.
+		# On Non-Linux, non-Windows kernels, binding to 127.0.0.1/24 addresses
+		# other than 127.0.0.1 might fail with EADDRNOTAVAIL.
 		#
 		# XXX A port available now may become unavailable by the time we start
 		# the postmaster.
 		if ($found == 1)
 		{
-			foreach my $addr (qw(127.0.0.1 0.0.0.0),
-				$use_tcp ? qw(127.0.0.2 127.0.0.3) : ())
+			foreach my $addr (qw(127.0.0.1),
+				$use_tcp ? qw(127.0.0.2 127.0.0.3 0.0.0.0) : ())
 			{
 				can_bind($addr, $port) or $found = 0;
 			}
-- 
2.21.0

