]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
httpd/async: require IO arg
authorEric Wong <e@80x24.org>
Wed, 25 Oct 2023 00:29:30 +0000 (00:29 +0000)
committerEric Wong <e@80x24.org>
Wed, 25 Oct 2023 07:28:34 +0000 (07:28 +0000)
Callers that want to requeue can call PublicInbox::DS::requeue
directly and not go through the convoluted argument handling
via PublicInbox::HTTPD::Async->new.

lib/PublicInbox/HTTPD/Async.pm
lib/PublicInbox/MailDiff.pm
lib/PublicInbox/SolverGit.pm

index b73d0c4b9f334cfd159ca69a095a0144fca365e5..2e4d8baa147203fea0e71cd7bd1d8565b7c38c45 100644 (file)
@@ -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
index c3ce93657f2c76bafe11ac84701e9692a1f3d986..908f223c7ebccd6e3c31c696e2989fa5a5017a47 100644 (file)
@@ -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};
        }
index 5f317f51d19141acfc1cc4fea3a8981a87ab9fe0..23d4d3d1ead08873e8f467868730a3c85faee49c 100644 (file)
@@ -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};
        }