diff options
author | Eric Wong <e@yhbt.net> | 2020-03-30 18:30:08 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-03-30 18:31:07 +0000 |
commit | 740db9e58da0cb548d6c9f6534e0047a96298c47 (patch) | |
tree | 6c42af3fd2486d8b12c2f40f095ae52351fdfa60 | |
parent | 2fc67a18b7ccd75ea6eb945f18203cbf4bcf228f (diff) | |
download | public-inbox-740db9e58da0cb548d6c9f6534e0047a96298c47.tar.gz |
User-supplied callbacks may fail, so capture the error instead of propagating it up the stack into the public-inbox-httpd event loop.
-rw-r--r-- | lib/PublicInbox/Qspawn.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index 34b6912f..aebcb1f7 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -234,7 +234,11 @@ sub rd_hdr ($) { length($$hdr_buf)); if (defined($r)) { $total_rd += $r; - $ret = $ph_cb->($total_rd, $hdr_buf, $ph_arg); + eval { $ret = $ph_cb->($total_rd, $hdr_buf, $ph_arg) }; + if ($@) { + log_err($self->{psgi_env}, "parse_hdr: $@"); + $ret = [ 500, [], [ "Internal error\n" ] ]; + } } else { # caller should notify us when it's ready: return if $! == EAGAIN; |