1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-01 14:21:49 +03:00

Only ever test for non-127.0.0.1 addresses on Windows in PostgresNode

This has been found to cause hangs where tcp usage is forced.

Alexey Kodratov

Discussion: https://postgr.es/m/82e271a9a11928337fcb5b5e57b423c0@postgrespro.ru

Backpatch to all live branches
This commit is contained in:
Andrew Dunstan 2021-04-21 10:21:22 -04:00
parent f8ba416a98
commit a2eb086042

View File

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