From: Eric Wong Date: Fri, 24 Jan 2025 09:18:56 +0000 (+0000) Subject: viewvcs: handle exceptions in on_destroy cb X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27e56d477c26a998c61dcc84c281b9f76c6a18e8;p=thirdparty%2Fpublic-inbox.git viewvcs: handle exceptions in on_destroy cb We need to account for File::Temp->newdir or autodie::open croaking on us in case the system is out of space or memory. These resource errors are already handled in our normal code path. However, this on_destroy codepath can be triggered when the solver request needs to be queued due to business. Thus we explicitly call the {-wcb} to ensure the socket isn't forgotten. --- diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 8d937cff0..96b60ee07 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -648,6 +648,7 @@ sub start_solver ($) { } $ctx->{-next_solver} = on_destroy \&next_solver; ++$solver_nr; + # ->newdir and open may croak $ctx->{-tmp} = File::Temp->newdir("solver.$ctx->{oid_b}-XXXX", TMPDIR => 1); $ctx->{lh} or open $ctx->{lh}, '+>>', "$ctx->{-tmp}/solve.log"; @@ -660,11 +661,14 @@ sub start_solver ($) { $solver->solve(@$ctx{qw(env lh oid_b hints)}); } -# run the next solver job when done and DESTROY-ed +# run the next solver job when done and DESTROY-ed (on_destroy cb) sub next_solver { --$solver_nr; + my $ctx = shift(@solver_q) // return; # XXX FIXME: client may've disconnected if it waited a long while - start_solver(shift(@solver_q) // return); + eval { start_solver($ctx) }; + warn "W: start_solver: $@" if $@; + html_page($ctx, 500) if $ctx->{-wcb}; } sub may_start_solver ($) {