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

Commitd80b432

Browse files
committed
check port manually
1 parentabb6801 commitd80b432

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

‎Cluster.pm

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@ use TestLib;
88
use Test::More;
99
use Cwd;
1010

11+
use Socket;
12+
13+
subcheck_port
14+
{
15+
my ($host,$port) =@_;
16+
my$iaddr = inet_aton($host);
17+
my$paddr = sockaddr_in($port,$iaddr);
18+
my$proto =getprotobyname("tcp");
19+
my$available = 0;
20+
21+
socket(SOCK, PF_INET, SOCK_STREAM,$proto)
22+
ordie"socket failed:$!";
23+
24+
if (bind(SOCK,$paddr) &&listen(SOCK, SOMAXCONN))
25+
{
26+
$available = 1;
27+
}
28+
29+
close(SOCK);
30+
diag("checking for port$port =$available\n");
31+
return$available;
32+
}
33+
1134
my%allocated_ports = ();
1235
suballocate_ports
1336
{
@@ -18,8 +41,7 @@ sub allocate_ports
1841
{
1942
my$port =int(rand() * 16384) + 49152;
2043
nextif$allocated_ports{$port};
21-
diag("checking for port$port\n");
22-
if (!TestLib::run_log(['pg_isready','-h',$host,'-p',$port]))
44+
if (check_port($host,$port))
2345
{
2446
$allocated_ports{$port} = 1;
2547
push(@allocated_now,$port);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp