]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/public-inbox-httpd
doc: lei blob: wording fixups, describe --remote
[public-inbox.git] / script / public-inbox-httpd
index b31b896d748ec952ab1c6a564b67bc2e49e63d03..a4dd809916c5116db301ec30c65f0919a48517ec 100755 (executable)
@@ -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,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),
        });