From f303b4add8ea18835f7f304910ba8fac3ee4f912 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 9 Sep 2020 06:26:16 +0000 Subject: wwwlisting: avoid hogging event loop By using the just-introduced ConfigIter class. And make ManifestJsGz a subclass of it to reduce duplication. --- lib/PublicInbox/WWW.pm | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lib/PublicInbox/WWW.pm') diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 93ab3c9d..85abf327 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -77,8 +77,12 @@ sub call { } # top-level indices and feeds - if ($path_info eq '/' || $path_info eq '/manifest.js.gz') { - www_listing($self)->call($env); + if ($path_info eq '/') { + require PublicInbox::WwwListing; + PublicInbox::WwwListing->response($ctx); + } elsif ($path_info eq '/manifest.js.gz') { + require PublicInbox::ManifestJsGz; + PublicInbox::ManifestJsGz->response($ctx); } elsif ($path_info =~ m!$INBOX_RE\z!o) { invalid_inbox($ctx, $1) || r301($ctx, $1); } elsif ($path_info =~ m!$INBOX_RE(?:/|/index\.html)?\z!o) { @@ -171,7 +175,6 @@ sub preload { } $self->cgit; $self->stylesheets_prepare($_) for ('', '../', '../../'); - $self->www_listing; $self->news_www; $pi_config->each_inbox(\&preload_inbox); } @@ -496,21 +499,13 @@ sub cgit { } } -sub www_listing { - my ($self) = @_; - $self->{www_listing} ||= do { - require PublicInbox::WwwListing; - PublicInbox::WwwListing->new($self); - } -} - # GET $INBOX/manifest.js.gz sub get_inbox_manifest ($$$) { my ($ctx, $inbox, $key) = @_; my $r404 = invalid_inbox($ctx, $inbox); return $r404 if $r404; require PublicInbox::ManifestJsGz; - PublicInbox::ManifestJsGz::response($ctx->{env}, [$ctx->{-inbox}]); + PublicInbox::ManifestJsGz->response($ctx); } sub get_attach { -- cgit v1.2.3-24-ge0c7