Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4e3682c

Browse files
committed
use standard port, if available
1 parent 7b1e095 commit 4e3682c

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

testeaux/Cluster.pm

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,24 @@ use PostgresNode;
77
use TestLib;
88
use Test::More;
99
use Cwd;
10-
use List::Util;
1110

12-
my %allocated_ports = ();
11+
my $max_port = 5431;
1312
sub allocate_ports
1413
{
1514
my @allocated_now = ();
1615
my ($host, $ports_to_alloc) = @_;
16+
my $port = $max_port + 1;
1717

1818
while ($ports_to_alloc > 0)
1919
{
20-
my $port = int(rand() * 16384) + 49152;
21-
22-
# # try to use ordinary ports if available
23-
# if (!@allocated_now)
24-
# my $port = 5432;
25-
# else
26-
# my $port = max(@allocated_now) + 1;
27-
28-
next if $allocated_ports{$port};
2920
diag("checking for port $port\n");
3021
if (!TestLib::run_log(['pg_isready', '-h', $host, '-p', $port]))
3122
{
32-
$allocated_ports{$port} = 1;
23+
$max_port = $port;
3324
push(@allocated_now, $port);
3425
$ports_to_alloc--;
3526
}
27+
$port++;
3628
}
3729

3830
return @allocated_now;

0 commit comments

Comments
 (0)