From 03344d346ba5b3640206b380725f91e241780ad7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 20 Jul 2021 08:58:58 +0000 Subject: httpd: fix SIGHUP by invalidating cache on reload Since we require separate PublicInbox::HTTPD instances for each listen socket address (in order to support {SERVER_} for PSGI env), the old cache needed to be invalidated on rare app refreshes. SIGHUP has always been broken in -httpd (but not -imapd or -nntpd) due to this cache. Update the daemon documentation and 5.10.1-ize some bits while we're in the area. --- t/httpd.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 't/httpd.t') diff --git a/t/httpd.t b/t/httpd.t index 0354a733..849f61bb 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -32,6 +32,10 @@ Date: Thu, 01 Jan 1970 06:06:06 +0000 nntp EOF }; + my $i2 = create_inbox 'test-2', sub { + my ($im, $ibx) = @_; + $im->add(eml_load('t/plack-qp.eml')) or xbail '->add'; + }; local $ENV{HOME} = $home; my $cmd = [ '-init', $group, $inboxdir, 'http://example.com/', $addr ]; ok(run_script($cmd), 'init ran properly'); @@ -64,6 +68,27 @@ EOF "$http_pfx/$group", "$tmpdir/dumb.git"), 0, 'clone successful'); + # test config reload + my $cfg = "$home/.public-inbox/config"; + open my $fh, '>>', $cfg or xbail "open: $!"; + print $fh <{inboxdir} + address = test-2\@example.com + url = https://example.com/test-2 +EOM + close $fh or xbail "close $!"; + $td->kill('HUP') or BAIL_OUT "failed to kill -httpd: $!"; + tick; # wait for HUP to take effect + my $buf = do { + my $c2 = tcp_connect($sock); + $c2->write("GET /test-2/qp\@example.com/raw HTTP/1.0\r\n\r\n") + or xbail "c2 write: $!"; + local $/; + <$c2> + }; + like($buf, qr!\AHTTP/1\.0 200\b!s, 'got 200 after reload for test-2'); + ok($td->kill, 'killed httpd'); $td->join; -- cgit v1.2.3-24-ge0c7