From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E29501F677 for ; Mon, 23 Oct 2023 08:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698050918; bh=dowhzmB9qf4jr/ZTeGnCMXIc5/ecluxGNGKG01Tdc6Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=z2cvUtyNdFy618VtM0RVMxHlEsANuCdTZg7fdcXbupMEe6fIl8ZLtt3rI8PZltNyi WmH8qG85+8fgArmeC9ynV70xRFLv3HEeyPpyDK24AC4WrieuIHr9e7WKgzGP3triS5 n+ImHpzJYzt6d3tPJR5usGg9hEDVYks8QM+HPQpY= From: Eric Wong To: spew@80x24.org Subject: [PATCH 07/18] httpd/async: require IO arg Date: Mon, 23 Oct 2023 08:48:26 +0000 Message-ID: <20231023084837.2804687-7-e@80x24.org> In-Reply-To: <20231023084837.2804687-1-e@80x24.org> References: <20231023084837.2804687-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 8 -------- lib/PublicInbox/MailDiff.pm | 7 +++---- lib/PublicInbox/SolverGit.pm | 10 +++------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm index b73d0c4b..2e4d8baa 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 c3ce9365..908f223c 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 5f317f51..23d4d3d1 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}; }