about summary refs log tree commit homepage
path: root/script
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-07-20 08:58:58 +0000
committerEric Wong <e@80x24.org>2021-07-20 21:45:19 +0000
commit03344d346ba5b3640206b380725f91e241780ad7 (patch)
treec6f550247020dcc57c95110b12a74ee7b692daa3 /script
parent41b03a53dd092738500320b5f976fa21b546f176 (diff)
downloadpublic-inbox-03344d346ba5b3640206b380725f91e241780ad7.tar.gz
Since we require separate PublicInbox::HTTPD instances for each
listen socket address (in order to support {SERVER_<NAME|PORT>}
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.
Diffstat (limited to 'script')
-rwxr-xr-xscript/public-inbox-httpd6
1 files changed, 4 insertions, 2 deletions
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
index b31b896d..7b0ec560 100755
--- a/script/public-inbox-httpd
+++ b/script/public-inbox-httpd
@@ -4,6 +4,7 @@
 #
 # Standalone HTTP server for public-inbox.
 use strict;
+use v5.10.1;
 use PublicInbox::Daemon;
 BEGIN {
         for (qw(Plack::Builder Plack::Util)) {
@@ -14,7 +15,7 @@ BEGIN {
         require PublicInbox::HTTPD;
 }
 
-my %httpds;
+my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_<NAME|PORT>}
 my $app;
 my $refresh = sub {
         if (@ARGV) {
@@ -37,12 +38,13 @@ my $refresh = sub {
                         sub { $www->call(@_) };
                 };
         }
+        %httpds = (); # invalidate cache
 };
 
 PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
         sub ($$$) { # post_accept
                 my ($client, $addr, $srv) = @_;
                 my $fd = fileno($srv);
-                my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
+                my $h = $httpds{$fd} //= PublicInbox::HTTPD->new($srv, $app);
                 PublicInbox::HTTP->new($client, $addr, $h),
         });