From: Eric Wong Date: Wed, 25 Oct 2023 00:29:30 +0000 (+0000) Subject: httpd/async: require IO arg X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82abcce5e42991db9bf8afb559a88708ff667697;p=thirdparty%2Fpublic-inbox.git httpd/async: require IO arg Callers that want to requeue can call PublicInbox::DS::requeue directly and not go through the convoluted argument handling via PublicInbox::HTTPD::Async->new. --- diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm index b73d0c4b9..2e4d8baa1 100644 --- a/lib/PublicInbox/HTTPD/Async.pm +++ b/lib/PublicInbox/HTTPD/Async.pm @@ -25,14 +25,6 @@ use PublicInbox::ProcessIONBF; # bidirectional socket in the future. sub new { my ($class, $io, $cb, $arg, $end_obj) = @_; - - # no $io? call $cb at the top of the next event loop to - # avoid recursion: - unless (defined($io)) { - PublicInbox::DS::requeue($cb ? $cb : $arg); - die '$end_obj unsupported w/o $io' if $end_obj; - return; - } my $self = bless { cb => $cb, # initial read callback arg => $arg, # arg for $cb diff --git a/lib/PublicInbox/MailDiff.pm b/lib/PublicInbox/MailDiff.pm index c3ce93657..908f223c7 100644 --- a/lib/PublicInbox/MailDiff.pm +++ b/lib/PublicInbox/MailDiff.pm @@ -59,8 +59,7 @@ sub next_smsg ($) { $ctx->write($ctx->_html_end); return $ctx->close; } - my $async = $self->{ctx}->{env}->{'pi-httpd.async'}; - $async->(undef, undef, $self) if $async # PublicInbox::HTTPD::Async->new + PublicInbox::DS::requeue($self) if $ctx->{env}->{'pi-httpd.async'}; } sub emit_msg_diff { @@ -125,8 +124,8 @@ sub event_step { sub begin_mail_diff { my ($self) = @_; - if (my $async = $self->{ctx}->{env}->{'pi-httpd.async'}) { - $async->(undef, undef, $self); # PublicInbox::HTTPD::Async->new + if ($self->{ctx}->{env}->{'pi-httpd.async'}) { + PublicInbox::DS::requeue($self); } else { event_step($self) while $self->{smsg}; } diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm index 5f317f51d..23d4d3d1e 100644 --- a/lib/PublicInbox/SolverGit.pm +++ b/lib/PublicInbox/SolverGit.pm @@ -386,12 +386,9 @@ sub event_step ($) { } sub next_step ($) { - my ($self) = @_; # if outside of public-inbox-httpd, caller is expected to be # looping event_step, anyways - my $async = $self->{psgi_env}->{'pi-httpd.async'} or return; - # PublicInbox::HTTPD::Async->new - $async->(undef, undef, $self); + PublicInbox::DS::requeue($_[0]) if $_[0]->{psgi_env}->{'pi-httpd.async'} } sub mark_found ($$$) { @@ -690,9 +687,8 @@ sub solve ($$$$$) { $self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] } dbg($self, "solving $oid_want ..."); - if (my $async = $env->{'pi-httpd.async'}) { - # PublicInbox::HTTPD::Async->new - $async->(undef, undef, $self); + if ($env->{'pi-httpd.async'}) { + PublicInbox::DS::requeue($self); } else { event_step($self) while $self->{user_cb}; }