Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit40e89e2

Browse files
committed
Try harder to detect a port conflict in PostgresNode.pm.
Commitfab84c7 tried to get away without doing an actual bind(),but buildfarm results show that that doesn't get the job done. So we mustreally bind to the target port --- and at least on my Linux box, we need alisten() as well, or conflicts won't be detected. We rely on SO_REUSEADDRto prevent problems from starting a postmaster on the socket immediatelyafter we've bound to it in the test code. (There may be platforms wherethat doesn't work too well. But fortunately, we only really care whetherthis works on Windows, and there the default behavior should be OK.)
1 parent63417b4 commit40e89e2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎src/test/perl/PostgresNode.pm

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,12 +859,18 @@ sub get_new_node
859859
# to open a TCP port on Unix.
860860
if ($found == 1)
861861
{
862-
my$iaddr = inet_aton($test_localhost);
863-
my$paddr = sockaddr_in($port,$iaddr);
864-
my$proto =getprotobyname("tcp");
865-
866-
socket(SOCK, PF_INET, SOCK_STREAM,$proto)ordie;
867-
$found = 0ifconnect(SOCK,$paddr);
862+
my$iaddr = inet_aton($test_localhost);
863+
my$paddr = sockaddr_in($port,$iaddr);
864+
my$proto =getprotobyname("tcp");
865+
866+
socket(SOCK, PF_INET, SOCK_STREAM,$proto)
867+
ordie"socket failed:$!";
868+
869+
# As in postmaster, don't use SO_REUSEADDR on Windows
870+
setsockopt(SOCK, SOL_SOCKET, SO_REUSEADDR,pack("l", 1))
871+
unless$TestLib::windows_os;
872+
(bind(SOCK,$paddr) &&listen(SOCK, SOMAXCONN))
873+
or$found = 0;
868874
close(SOCK);
869875
}
870876
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp