]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-httpd
lei export-kw: don't recreate deleted IMAP folders
[public-inbox.git] / script / public-inbox-httpd
index 3befdab800fbea9bc385cc2fbf2277eff22f0a11..a4dd809916c5116db301ec30c65f0919a48517ec 100755 (executable)
@@ -1,9 +1,10 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # 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,14 @@ 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) = @_;
+       sub ($$$) { # Listener->{post_accept}
+               my ($client, $addr, $srv, $tls_wrap) = @_;
                my $fd = fileno($srv);
-               my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
+               my $h = $httpds{$fd} //=
+                       PublicInbox::HTTPD->new($srv, $app, $client);
                PublicInbox::HTTP->new($client, $addr, $h),
        });