* [PATCH] viewvcs: handle exceptions in on_destroy cb
@ 2025-01-24 9:18 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2025-01-24 9:18 UTC (permalink / raw)
To: meta
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.
---
lib/PublicInbox/ViewVCS.pm | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 8d937cff..96b60ee0 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 ($) {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-24 9:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 9:18 [PATCH] viewvcs: handle exceptions in on_destroy cb Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).