We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentabb6801 commitd80b432Copy full SHA for d80b432
Cluster.pm
@@ -8,6 +8,29 @@ use TestLib;
8
use Test::More;
9
use Cwd;
10
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
34
my%allocated_ports = ();
35
suballocate_ports
36
{
@@ -18,8 +41,7 @@ sub allocate_ports
41
42
my$port =int(rand() * 16384) + 49152;
43
nextif$allocated_ports{$port};
-diag("checking for port$port\n");
-if (!TestLib::run_log(['pg_isready','-h',$host,'-p',$port]))
44
+if (check_port($host,$port))
45
46
$allocated_ports{$port} = 1;
47
push(@allocated_now,$port);