* [PATCH 07/26] httpd/async: require IO arg
2023-10-25 0:29 7% [PATCH 00/26] process management simplifications Eric Wong
@ 2023-10-25 0:29 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-10-25 0:29 UTC (permalink / raw)
To: meta
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};
}
^ permalink raw reply related [relevance 6%]
* [PATCH 00/26] process management simplifications
@ 2023-10-25 0:29 7% Eric Wong
2023-10-25 0:29 6% ` [PATCH 07/26] httpd/async: require IO arg Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-10-25 0:29 UTC (permalink / raw)
To: meta
The convoluted HTTPD/Async code and is now gone and replaced
with the simpler InputPipe (originally developed for lei).
Fortunately, the s/psgi_return/psgi_yield/ change went more
smoothly than I expected.
cindex gets some simplifications, too; which will be helpful
since more work is required on that code. I didn't get a
chance to use the split out Limiter+Qspawn, though...
3/26 is a fairly large philosophy change to use temporary files
over pipes, but it's probably fine as it's simpler and more
straightforward data flow and only used for small outputs which
can fit in memory, so unlikely to hit disk.
9/26 is the major change which was enabled by a change made
4 years ago.
Eric Wong (26):
limiter: split out from qspawn
spawn: support synchronous run_qx
psgi_qx: use a temporary file rather than pipe
www_coderepo: capture uses a flattened list
qspawn: psgi_return allows list for callback args
qspawn: drop unused err arg for ->event_step
httpd/async: require IO arg
xt/check-run: call DS->Reset after all tests
qspawn: introduce new psgi_yield API
repo_atom: switch to psgi_yield
repo_snapshot: psgi_yield
viewvcs: psgi_yield
www_altid: switch to psgi_yield
cgit: switch to psgi_yield
www_coderepo: psgi_yield
drop psgi_return, httpd/async and GetlineBody
qspawn: use WwwStatic for fallbacks and error code
qspawn: simplify internal argument passing
cidx_log_p: don't bother with F_SETPIPE_SZ
cindex: avoid awaitpid for popen
cindex: use timer for inits
cindex: start using run_await to simplify code
cindex: use run_await to read extensions.objectFormat
cindex: drop XH_PID global
cindex: use run_await wrapper for git commands
cindex: use sysread for generating fingerprint
MANIFEST | 5 +-
lib/PublicInbox/Aspawn.pm | 34 +++
lib/PublicInbox/Cgit.pm | 2 +-
lib/PublicInbox/CidxLogP.pm | 3 +-
lib/PublicInbox/CodeSearchIdx.pm | 236 +++++++++----------
lib/PublicInbox/Config.pm | 4 +-
lib/PublicInbox/GetlineBody.pm | 46 ----
lib/PublicInbox/GetlineResponse.pm | 40 ++++
lib/PublicInbox/Git.pm | 6 +
lib/PublicInbox/GitHTTPBackend.pm | 17 +-
lib/PublicInbox/GzipFilter.pm | 5 +-
lib/PublicInbox/HTTP.pm | 8 +-
lib/PublicInbox/HTTPD.pm | 5 +-
lib/PublicInbox/HTTPD/Async.pm | 109 ---------
lib/PublicInbox/Inbox.pm | 4 +-
lib/PublicInbox/InputPipe.pm | 12 +-
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/Limiter.pm | 47 ++++
lib/PublicInbox/MailDiff.pm | 8 +-
lib/PublicInbox/Qspawn.pm | 349 +++++++++++------------------
lib/PublicInbox/RepoAtom.pm | 6 +-
lib/PublicInbox/RepoSnapshot.pm | 2 +-
lib/PublicInbox/SearchIdx.pm | 19 +-
lib/PublicInbox/SolverGit.pm | 10 +-
lib/PublicInbox/Spawn.pm | 69 ++++--
lib/PublicInbox/ViewVCS.pm | 7 +-
lib/PublicInbox/WwwAltId.pm | 6 +-
lib/PublicInbox/WwwCoderepo.pm | 12 +-
t/dir_idle.t | 1 -
t/fake_inotify.t | 2 -
t/httpd-corner.psgi | 14 +-
t/httpd-corner.t | 12 +-
t/qspawn.t | 3 +-
t/spawn.t | 13 +-
xt/check-run.t | 2 +
35 files changed, 515 insertions(+), 605 deletions(-)
create mode 100644 lib/PublicInbox/Aspawn.pm
delete mode 100644 lib/PublicInbox/GetlineBody.pm
create mode 100644 lib/PublicInbox/GetlineResponse.pm
delete mode 100644 lib/PublicInbox/HTTPD/Async.pm
create mode 100644 lib/PublicInbox/Limiter.pm
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-10-25 0:29 7% [PATCH 00/26] process management simplifications Eric Wong
2023-10-25 0:29 6% ` [PATCH 07/26] httpd/async: require IO arg Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).