Skip to content

Commit

Permalink
tests: repair race in maxconns.t test
Browse files Browse the repository at this point in the history
lsitener thread may not have actually accepted everything by the time we
start closing them, so it might not show rejected connections.
  • Loading branch information
dormando committed Feb 9, 2022
1 parent f393a1a commit cbb8efb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions t/maxconns.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,21 @@ sub test_maxconns {
}
}

my $failed = 1;
for (1 .. 5) {
$stats = mem_stats($stat_sock);
if ($stats->{rejected_connections} != 0) {
$failed = 0;
last;
}
sleep 1;
}
is($failed, 0, "rejected connections were observed.");

for my $s (@sockets) {
$s->close();
}

$stats = mem_stats($stat_sock);
cmp_ok($stats->{rejected_connections}, '>', '1', 'rejected connections recorded');
$server->stop;
$stat_sock->close();
}
Expand Down

0 comments on commit cbb8efb

Please sign in to comment.