From cefb0b648025e3f92718294d9e5e7d214e431e6b Mon Sep 17 00:00:00 2001 From: Joe Cooper Date: Sat, 15 Aug 2026 01:35:02 -0500 Subject: [PATCH] Don't wait forever for a client that connects but never sends --- miniserv.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/miniserv.pl b/miniserv.pl index efefad1df..3ad64bef7 100755 --- a/miniserv.pl +++ b/miniserv.pl @@ -915,6 +915,13 @@ while(1) { # Initialize SSL for this connection if ($use_ssl) { my $byte = ''; + # Don't wait forever for a client that + # connects but never sends anything + my $pmask; + vec($pmask, fileno(SOCK), 1) = 1; + select($pmask, undef, undef, + $config{'peek_timeout'} || 60) + || exit; # Look at the first byte of the socket # buffer but don't consume it recv(SOCK, $byte, 1, MSG_PEEK);