]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Qspawn.pm
qspawn: drop lineno from command failure warning
[public-inbox.git] / lib / PublicInbox / Qspawn.pm
index c4708c0fe035088aa7de392d7244aabf1d370d2e..5e4fd5cb8541a2a8202d188ae1fd73c88fe64188 100644 (file)
@@ -28,7 +28,6 @@ package PublicInbox::Qspawn;
 use v5.12;
 use PublicInbox::Spawn qw(popen_rd);
 use PublicInbox::GzipFilter;
-use PublicInbox::DS qw(awaitpid);
 use Scalar::Util qw(blessed);
 
 # n.b.: we get EAGAIN with public-inbox-httpd, and EINTR on other PSGI servers
@@ -86,7 +85,7 @@ sub finalize ($) {
                if (my $dst = $self->{qsp_err}) {
                        $$dst .= $$dst ? " $err" : "; $err";
                }
-               warn "@{$self->{cmd}}: $err" if !$self->{-quiet};
+               warn "@{$self->{cmd}}: $err\n" if !$self->{-quiet};
        }
 
        my ($env, $qx_cb, $qx_arg, $qx_buf) =
@@ -142,20 +141,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);
        }
 }