Skip to content

Commit ff91b1e

Browse files
committed
use standard port, if available
1 parent b6d1e71 commit ff91b1e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

contrib/mmts/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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy