]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Qspawn.pm
qspawn: more generic command chaining
[public-inbox.git] / lib / PublicInbox / Qspawn.pm
index 6e24538959517b00ec1179f87318a9d875ab3db8..9ca6b3dbbcc98c6a761e34fe4cc7e94f4a94ccd4 100644 (file)
@@ -237,7 +237,12 @@ sub psgi_return_init_cb {
                        $self->{rpipe}->close;
                        event_step($self);
                }
-               $wcb->($r) if ref($r) eq 'ARRAY';
+               if (ref($r) eq 'ARRAY') { # error
+                       $wcb->($r)
+               } elsif (ref($r) eq 'CODE') { # chain another command
+                       $r->($wcb)
+               }
+               # else do nothing
        } elsif ($async) {
                # done reading headers, handoff to read body
                my $fh = $wcb->($r); # scalar @$r == 2