mirror of https://github.com/openssl/openssl.git
Fix a hang in tests that use sessionfile
The logic for testing whether the sessionfile has been created or not was faulty and could result in race conditions. If you "lose" the tests hang waiting for a session file that's never going to arrive. Fixes #2950 Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2955)
This commit is contained in:
parent
3a80bd29be
commit
db0e0abb88
|
@ -284,32 +284,30 @@ sub clientstart
|
||||||
|
|
||||||
#Wait for either the server socket or the client socket to become readable
|
#Wait for either the server socket or the client socket to become readable
|
||||||
my @ready;
|
my @ready;
|
||||||
while(!(TLSProxy::Message->end) && (@ready = $sel->can_read)) {
|
my $ctr = 0;
|
||||||
|
while( (!(TLSProxy::Message->end)
|
||||||
|
|| (defined $self->sessionfile()
|
||||||
|
&& (-s $self->sessionfile()) == 0))
|
||||||
|
&& $ctr < 10
|
||||||
|
&& (@ready = $sel->can_read(1))) {
|
||||||
foreach my $hand (@ready) {
|
foreach my $hand (@ready) {
|
||||||
if ($hand == $server_sock) {
|
if ($hand == $server_sock) {
|
||||||
$server_sock->sysread($indata, 16384) or goto END;
|
$server_sock->sysread($indata, 16384) or goto END;
|
||||||
$indata = $self->process_packet(1, $indata);
|
$indata = $self->process_packet(1, $indata);
|
||||||
$client_sock->syswrite($indata);
|
$client_sock->syswrite($indata);
|
||||||
|
$ctr = 0;
|
||||||
} elsif ($hand == $client_sock) {
|
} elsif ($hand == $client_sock) {
|
||||||
$client_sock->sysread($indata, 16384) or goto END;
|
$client_sock->sysread($indata, 16384) or goto END;
|
||||||
$indata = $self->process_packet(0, $indata);
|
$indata = $self->process_packet(0, $indata);
|
||||||
$server_sock->syswrite($indata);
|
$server_sock->syswrite($indata);
|
||||||
|
$ctr = 0;
|
||||||
} else {
|
} else {
|
||||||
print "Err\n";
|
$ctr++
|
||||||
goto END;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (my $ctr = 0;
|
die "No progress made" if $ctr >= 10;
|
||||||
defined $self->sessionfile()
|
|
||||||
&& (!(-f $self->sessionfile()) || $ctr == 3);
|
|
||||||
$ctr++) {
|
|
||||||
sleep 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
die "Session file not created"
|
|
||||||
if (defined $self->sessionfile() && !(-f $self->sessionfile()));
|
|
||||||
|
|
||||||
END:
|
END:
|
||||||
print "Connection closed\n";
|
print "Connection closed\n";
|
||||||
|
|
Loading…
Reference in New Issue