diff options
author | Eric Wong <e@80x24.org> | 2019-12-25 07:50:39 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-26 10:48:19 +0000 |
commit | dd57a7d007bf756d856fe3d2b414657ebf009941 (patch) | |
tree | 9b68c7531d1c50b7750c26eccd48c0c79b88cb4a /lib/PublicInbox/HTTPD | |
parent | 5c887bfc4ccc6fd79e29d89ee8edfccd5cd9685b (diff) | |
download | public-inbox-dd57a7d007bf756d856fe3d2b414657ebf009941.tar.gz |
This will tie into the DS event loop if that's used, but event_step an be called directly without relying on the event loop from Apache or other HTTP servers (or PSGI tests).
Diffstat (limited to 'lib/PublicInbox/HTTPD')
-rw-r--r-- | lib/PublicInbox/HTTPD/Async.pm | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm index d182c118..8956f719 100644 --- a/lib/PublicInbox/HTTPD/Async.pm +++ b/lib/PublicInbox/HTTPD/Async.pm @@ -10,7 +10,7 @@ package PublicInbox::HTTPD::Async; use strict; use warnings; use base qw(PublicInbox::DS); -use fields qw(cb arg end end_arg); +use fields qw(cb arg end_obj); use Errno qw(EAGAIN); use PublicInbox::Syscall qw(EPOLLIN EPOLLET); @@ -18,13 +18,13 @@ use PublicInbox::Syscall qw(EPOLLIN EPOLLET); # $io is a read-only pipe ($rpipe) for now, but may be a # bidirectional socket in the future. sub new { - my ($class, $io, $cb, $arg, $end, $end_arg) = @_; + 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 unsupported w/o $io' if $end; + die '$end_obj unsupported w/o $io' if $end_obj; return; } @@ -33,8 +33,7 @@ sub new { $self->SUPER::new($io, EPOLLIN | EPOLLET); $self->{cb} = $cb; # initial read callback, later replaced by main_cb $self->{arg} = $arg; # arg for $cb - $self->{end} = $end; # like END {}, but only for this object - $self->{end_arg} = $end_arg; # arg for $end + $self->{end_obj} = $end_obj; # like END{}, can ->event_step $self; } @@ -98,8 +97,11 @@ sub close { $self->SUPER::close; # DS::close # we defer this to the next timer loop since close is deferred - if (my $end = delete $self->{end}) { - PublicInbox::DS::requeue($end); + if (my $end_obj = delete $self->{end_obj}) { + # this calls $end_obj->event_step + # (likely PublicInbox::Qspawn::event_step, + # NOT PublicInbox::HTTPD::Async::event_step) + PublicInbox::DS::requeue($end_obj); } } |