diff options
author | Eric Wong <e@80x24.org> | 2019-11-24 00:22:25 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-11-24 21:34:37 +0000 |
commit | 64f3a6aded930c82e35a466b2dad58299d29ee6e (patch) | |
tree | 6fdc768aeddbb51874db509bed2e9c26a1c074d6 /t/httpd-corner.t | |
parent | 08071ffbd957c13df35979ac88711ed9040b863a (diff) | |
download | public-inbox-64f3a6aded930c82e35a466b2dad58299d29ee6e.tar.gz |
We need to ensure the worker process is terminated before starting a new connection, so leave a persistent HTTP/1.1 connection open and wait for the SIGKILL to take effect and drop the client.
Diffstat (limited to 't/httpd-corner.t')
-rw-r--r-- | t/httpd-corner.t | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/t/httpd-corner.t b/t/httpd-corner.t index b063d9fa..cc36c7e1 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -76,17 +76,22 @@ my $spawn_httpd = sub { $spawn_httpd->(); if ('test worker death') { my $conn = conn_for($sock, 'killed worker'); - $conn->write("GET /pid HTTP/1.0\r\n\r\n"); - ok($conn->read(my $buf, 8192), 'read response'); - my ($head, $body) = split(/\r\n\r\n/, $buf); - like($body, qr/\A[0-9]+\z/, '/pid response'); - my $pid = $body; + $conn->write("GET /pid HTTP/1.1\r\nHost:example.com\r\n\r\n"); + my $pid; + while (defined(my $line = $conn->getline)) { + next unless $line eq "\r\n"; + chomp($pid = $conn->getline); + last; + } + like($pid, qr/\A[0-9]+\z/, '/pid response'); is(kill('KILL', $pid), 1, 'killed worker'); + is($conn->getline, undef, 'worker died and EOF-ed client'); $conn = conn_for($sock, 'respawned worker'); $conn->write("GET /pid HTTP/1.0\r\n\r\n"); - ok($conn->read($buf, 8192), 'read response'); - ($head, $body) = split(/\r\n\r\n/, $buf); + ok($conn->read(my $buf, 8192), 'read response'); + my ($head, $body) = split(/\r\n\r\n/, $buf); + chomp($body); like($body, qr/\A[0-9]+\z/, '/pid response'); isnt($body, $pid, 'respawned worker'); } |