Commit e382876248 for openssl.org
commit e382876248092d281a5250b9de0ea76af29e85a1
Author: Bob Beck <beck@openssl.org>
Date: Sun Aug 16 17:07:36 2026 -0700
Hold DTLS s_server stdin open with a pipe rather than a timer
TLSProxy gave a DTLS s_server a stdin that was the read end of a pipe
from a "perl -e sleep(10)" process, so that it would not see EOF while
the test ran. Nothing ever closed that early, so the recipe paid out
the remainder of the ten seconds before it could exit.
Use a plain pipe and keep the write end in the proxy, closing it in the
teardown that already reaps s_server. Stdin then stays open exactly as
long as the test needs and no longer, with no timer to tune.
70-test_sslrecords goes from 13.7 to 4.0 seconds on my mac
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Merge-date: Tue Sep 1 14:17:22 2026
Merged-from: https://github.com/openssl/openssl/pull/32404
diff --git a/util/perl/TLSProxy/Proxy.pm b/util/perl/TLSProxy/Proxy.pm
index b223caabc6..5225d073e5 100644
--- a/util/perl/TLSProxy/Proxy.pm
+++ b/util/perl/TLSProxy/Proxy.pm
@@ -317,10 +317,23 @@ sub start
open(my $savedin, "<&STDIN");
- # Temporarily replace STDIN so that sink process can inherit it...
- open(STDIN, "$^X -e 'sleep(10)' |") if $self->{isdtls};
+ # DTLS s_server exits when its stdin reaches EOF, so it needs one that
+ # stays open for as long as the test does. Give it the read end of a
+ # pipe and keep the write end here; closing that in clientstart() is
+ # what lets it finish.
+ my $stdin_holder;
+ if ($self->{isdtls}) {
+ my $rd;
+
+ # A previous run that died before its teardown may have left one.
+ close($self->{stdin_holder}) if defined($self->{stdin_holder});
+ pipe($rd, $stdin_holder) or die "Failed to create stdin pipe: $!\n";
+ open(STDIN, "<&", $rd) or die "Failed to replace STDIN: $!\n";
+ close($rd);
+ }
$pid = open(STDIN, "$execcmd 2>&1 |") or die "Failed to $execcmd: $!\n";
$self->{real_serverpid} = $pid;
+ $self->{stdin_holder} = $stdin_holder;
# Process the output from s_server until we find the ACCEPT line, which
# tells us what the accepting address and port are.
@@ -596,6 +609,13 @@ sub clientstart
my $pid;
if (--$self->{serverconnects} == 0) {
+ # Let a DTLS s_server see EOF on its stdin, so that it exits and the
+ # sink process reading its output finishes too. This has to happen
+ # before either is waited for.
+ if (defined($self->{stdin_holder})) {
+ close($self->{stdin_holder});
+ $self->{stdin_holder} = undef;
+ }
$pid = $self->{serverpid};
print "Waiting for 'perl -ne print' process to close: $pid...\n";
$pid = waitpid($pid, 0);