X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=script%2Fpublic-inbox-httpd;h=a4dd809916c5116db301ec30c65f0919a48517ec;hb=a34e62ec1d84eafb67cc63532a383d15a18dcc4d;hp=b8159f3a5db233272cc10eaf83bfa8c924058e71;hpb=a3f00c4a7851b98b81a2fcb31d5ed131908e22de;p=public-inbox.git
diff --git a/script/public-inbox-httpd b/script/public-inbox-httpd
index b8159f3a..a4dd8099 100755
--- a/script/public-inbox-httpd
+++ b/script/public-inbox-httpd
@@ -1,9 +1,10 @@
#!/usr/bin/perl -w
-# Copyright (C) 2016-2020 all contributors
+# Copyright (C) 2016-2021 all contributors
# License: AGPL-3.0+
#
# Standalone HTTP server for public-inbox.
use strict;
+use v5.10.1;
use PublicInbox::Daemon;
BEGIN {
for (qw(Plack::Builder Plack::Util)) {
@@ -13,7 +14,8 @@ BEGIN {
require PublicInbox::HTTP;
require PublicInbox::HTTPD;
}
-my %httpds;
+
+my %httpds; # per-listen-FD mapping for HTTPD->{env}->{SERVER_}
my $app;
my $refresh = sub {
if (@ARGV) {
@@ -36,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),
});