about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-01-19 20:32:35 +0000
committerEric Wong <e@80x24.org>2023-01-19 20:54:22 +0000
commit876ee62a686c66037427232541c0ca4ebebfff94 (patch)
tree437d3af371b9462612f29ece030d1bae91608ce9
parenta6a04af500851bcff8a5ef3341d522a3a0dbefe5 (diff)
downloadpublic-inbox-876ee62a686c66037427232541c0ca4ebebfff94.tar.gz
This makes control flow slightly less confusing.
-rw-r--r--lib/PublicInbox/Qspawn.pm16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index c4708c0f..de74b174 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -142,20 +142,20 @@ sub start ($$$) {
 
 sub psgi_qx_init_cb { # this may be PublicInbox::HTTPD::Async {cb}
         my ($self) = @_;
-        my $async = delete $self->{async}; # PublicInbox::HTTPD::Async
         my ($r, $buf);
-        my $qx_fh = $self->{qx_fh};
 reread:
         $r = sysread($self->{rpipe}, $buf, 65536);
-        if ($async) {
-                $async->async_pass($self->{psgi_env}->{'psgix.io'},
-                                        $qx_fh, \$buf);
-        } elsif (defined $r) {
-                $r ? (print $qx_fh $buf) : event_step($self, undef);
-        } else {
+        if (!defined($r)) {
                 return if $! == EAGAIN; # try again when notified
                 goto reread if $! == EINTR;
                 event_step($self, $!);
+        } elsif (my $as = delete $self->{async}) { # PublicInbox::HTTPD::Async
+                $as->async_pass($self->{psgi_env}->{'psgix.io'},
+                                $self->{qx_fh}, \$buf);
+        } elsif ($r) { # generic PSGI:
+                print { $self->{qx_fh} } $buf;
+        } else { # EOF
+                event_step($self, undef);
         }
 }