@@ -977,28 +977,25 @@ sub get_new_node
977
977
$found = 0 if ($node -> port == $port );
978
978
}
979
979
980
- # Check to see if anything else is listening on this TCP port. This
981
- # is *necessary* on $use_tcp (Windows) configurations. Seek a port
982
- # available for all possible listen_addresses values, for own_host
983
- # nodes and so the caller can harness this port for the widest range
984
- # of purposes . The 0.0.0.0 test achieves that for post-2006 Cygwin,
985
- # which automatically sets SO_EXCLUSIVEADDRUSE. The same holds for
986
- # MSYS (a Cygwin fork) . Testing 0 .0.0.0 is insufficient for Windows
987
- # native Perl (https://stackoverflow.com/a/14388707), so we also test
988
- # individual addresses .
980
+ # Check to see if anything else is listening on this TCP port.
981
+ # Seek a port available for all possible listen_addresses values,
982
+ # so callers can harness this port for the widest range of purposes.
983
+ # The 0.0.0.0 test achieves that for MSYS, which automatically sets
984
+ # SO_EXCLUSIVEADDRUSE . Testing 0.0.0.0 is insufficient for Windows
985
+ # native Perl (https://stackoverflow.com/a/14388707), so we also
986
+ # have to test individual addresses . Doing that for 127 .0.0/24
987
+ # addresses other than 127.0.0.1 might fail with EADDRNOTAVAIL on
988
+ # non-Linux, non-Windows kernels .
989
989
#
990
- # This seems like a good idea on Unixen as well, even though we don't
991
- # ask the postmaster to open a TCP port on Unix. On Non-Linux,
992
- # non-Windows kernels, binding to 127.0.0.1/24 addresses other than
993
- # 127.0.0.1 might fail with EADDRNOTAVAIL. Binding to 0.0.0.0 is
994
- # unnecessary on non-Windows systems.
995
- #
996
- # XXX A port available now may become unavailable by the time we start
997
- # the postmaster.
990
+ # Thus, 0.0.0.0 and individual 127.0.0/24 addresses are tested
991
+ # only on Windows and only when TCP usage is requested.
998
992
if ($found == 1)
999
993
{
1000
994
foreach my $addr (qw( 127.0.0.1) ,
1001
- $use_tcp ? qw( 127.0.0.2 127.0.0.3 0.0.0.0) : ())
995
+ $use_tcp ? qw( 127.0.0.2 127.0.0.3 0.0.0.0) : ())
996
+ $use_tcp && $TestLib::windows_os
997
+ ? qw( 127.0.0.2 127.0.0.3 0.0.0.0)
998
+ : ())
1002
999
{
1003
1000
can_bind($addr , $port ) or $found = 0;
1004
1001
}
0 commit comments