From dc9dfd51551c0b6d6864cc4ddf0352a24af762b2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 21 Sep 2026 19:55:57 +0100 Subject: [PATCH 3/3] tests: Test EINTR I have tested this test, by experimentally reverting Handle EINTR and read errors correctly > 1..36 > ok 1 - constructor set family properly > ok 2 - Constructor set port correctly > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49019/ > ok 3 - pid is numeric > ok 4 - Returns a page > ok 5 - constructor set family properly > ok 6 - Constructor set port correctly > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49020/ > ok 7 - pid is numeric > ok 8 - Returns a page > ok 9 - constructor set family properly > ok 10 - Constructor set port correctly > SlowServer: You can connect to your server at http://localhost:49021/ > ok 11 - pid is numeric > ok 12 - Returns a page > ok 13 - constructor set family properly > ok 14 - Constructor set port correctly > SlowServer: You can connect to your server at http://localhost:49022/ > ok 15 - pid is numeric > ok 16 - Returns a page > ok 17 - family OK > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49023/ > ok 18 - pid is numeric > ok 19 - Returns a page > ok 20 - knows what a request isn't > ok 21 - HTTP/1.1 request > ok 22 - HTTP/0.9 request > # SIGWINCH received > not ok 23 - HTTP/1.1 request with EINTR > # Failed test 'HTTP/1.1 request with EINTR' > # at t/01live.t line 95. > # 'HTTP/1.0 400 Bad request > # Content-Type: text/html > # Content-Length: 193 > # > # > # > # Bad Request > # > # > #

Bad Request

> # > #

Your browser sent a request which this web server could not > # grok.

> # > # > # ' > # doesn't match '/Congratulations/' > ok 24 - Signaled 1 process successfully > ok 25 - family OK > HTTP::Server::Simple::CGI: You can connect to your server at http://localhost:49023/ > ok 26 - pid is numeric > ok 27 - Returns a page > ok 28 - knows what a request isn't > ok 29 - HTTP/1.1 request > ok 30 - HTTP/0.9 request > # SIGWINCH received > not ok 31 - HTTP/1.1 request with EINTR > # Failed test 'HTTP/1.1 request with EINTR' > # at t/01live.t line 95. > # 'HTTP/1.0 400 Bad request > # Content-Type: text/html > # Content-Length: 193 > # > # > # > # Bad Request > # > # > #

Bad Request

> # > #

Your browser sent a request which this web server could not > # grok.

> # > # > # ' > # doesn't match '/Congratulations/' > ok 32 - Signaled 1 process successfully > ok 33 - Killed PID: 30838 > ok 34 - Killed PID: 30839 > ok 35 - Killed PID: 30840 > ok 36 - Killed PID: 30846 > # Looks like you failed 2 tests of 36. --- t/01live.t | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/t/01live.t b/t/01live.t index 272a42e..f7af49a 100644 --- a/t/01live.t +++ b/t/01live.t @@ -21,10 +21,10 @@ my $RUN_IPV6 = eval { return 1; }; if ( $RUN_IPV6) { - plan tests => 34; + plan tests => 36; } else { diag("Skipping IPv6"); - plan tests => 17; + plan tests => 18; } use HTTP::Server::Simple; @@ -53,6 +53,7 @@ for my $class (@classes) { $PORT++; # don't reuse the port incase your bogus os doesn't release in time } +$SIG{WINCH} = sub { note "SIGWINCH received"; }; # See EINTR test, below for my $fam ( AF_INET, AF_INET6 ) { next if ($fam == AF_INET6 && not $RUN_IPV6); @@ -64,7 +65,7 @@ for my $fam ( AF_INET, AF_INET6 ) { like($pid, '/^-?\d+$/', 'pid is numeric'); select(undef,undef,undef,0.2); # wait a sec SKIP: { - skip "No localhost for $fam", 4 unless defined $s->host; + skip "No localhost for $fam", 5 unless defined $s->host; my $content=fetch($fam, "GET / HTTP/1.1", ""); like($content, '/Congratulations/', "Returns a page"); @@ -80,6 +81,18 @@ for my $fam ( AF_INET, AF_INET6 ) { like(fetch($fam, "GET /"), '/Congratulations/', "HTTP/0.9 request"); + + like(fetch_interactive($fam, sub { + # Arrange for the server to get EINTR, by sending part of the request, + # and then a SIGWINCH. (We choose SIGWINCH because it's a harmless signal + # that is normally ignored, but which an application might want to handle.) + # Tests for regression of https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1143215 + (send SOCK, "GET", 0) or die "send G: $!"; + sleep 1; + kill('WINCH',$pid) or die "send SIGWINCH: $!"; + sleep 1; + (send SOCK, " / HTTP/1.1\015\012\015\012", 0) or die "send ET etc.: $!"; + }), '/Congratulations/', "HTTP/1.1 request with EINTR"); } is(kill(9,$pid),1,'Signaled 1 process successfully'); -- 2.47.3