* [PATCH] lei q: guard query_done against die()
@ 2021-10-15 15:52 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-10-15 15:52 UTC (permalink / raw)
To: meta
v2w->wq_do('done') may die on I/O errors, and likely other
places. Just guard the entire block with an eval and ->fail
as appropriate.
---
lib/PublicInbox/LeiXSearch.pm | 75 ++++++++++++++++++-----------------
1 file changed, 38 insertions(+), 37 deletions(-)
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index fd2c8a37..4aa2a81c 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -412,47 +412,48 @@ sub xsearch_done_wait { # dwaitpid callback
sub query_done { # EOF callback for main daemon
my ($lei) = @_;
local $PublicInbox::LEI::current_lei = $lei;
- my $l2m = delete $lei->{l2m};
- delete $lei->{lxs};
- ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) and
- warn "BUG: {sto} missing with --mail-sync";
- $lei->sto_done_request if $lei->{sto};
- if (my $v2w = delete $lei->{v2w}) {
- $v2w->wq_do('done');
- $v2w->wq_close;
- }
- $lei->{ovv}->ovv_end($lei);
- my $start_mua;
- if ($l2m) { # close() calls LeiToMail reap_compress
- if (my $out = delete $lei->{old_1}) {
- if (my $mbout = $lei->{1}) {
- close($mbout) or return $lei->fail(<<"");
-Error closing $lei->{ovv}->{dst}: $!
+ eval {
+ my $l2m = delete $lei->{l2m};
+ delete $lei->{lxs};
+ ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) and
+ warn "BUG: {sto} missing with --mail-sync";
+ $lei->sto_done_request if $lei->{sto};
+ if (my $v2w = delete $lei->{v2w}) {
+ my $wait = $v2w->wq_do('done'); # may die
+ $v2w->wq_close;
+ }
+ $lei->{ovv}->ovv_end($lei);
+ if ($l2m) { # close() calls LeiToMail reap_compress
+ if (my $out = delete $lei->{old_1}) {
+ if (my $mbout = $lei->{1}) {
+ close($mbout) or die <<"";
+Error closing $lei->{ovv}->{dst}: \$!=$! \$?=$?
+ }
+ $lei->{1} = $out;
+ }
+ if ($l2m->lock_free) {
+ $l2m->poke_dst;
+ $lei->poke_mua;
+ } else { # mbox users
+ delete $l2m->{mbl}; # drop dotlock
}
- $lei->{1} = $out;
- }
- if ($l2m->lock_free) {
- $l2m->poke_dst;
- $lei->poke_mua;
- } else { # mbox users
- delete $l2m->{mbl}; # drop dotlock
- $start_mua = 1;
}
- }
- if ($lei->{-progress}) {
- my $tot = $lei->{-mset_total} // 0;
- my $nr = $lei->{-nr_write} // 0;
- if ($l2m) {
- my $m = "# $nr written to " .
- "$lei->{ovv}->{dst} ($tot matches)";
- $nr ? $lei->qfin($m) : $lei->qerr($m);
- } else {
- $lei->qerr("# $tot matches");
+ if ($lei->{-progress}) {
+ my $tot = $lei->{-mset_total} // 0;
+ my $nr = $lei->{-nr_write} // 0;
+ if ($l2m) {
+ my $m = "# $nr written to " .
+ "$lei->{ovv}->{dst} ($tot matches)";
+ $nr ? $lei->qfin($m) : $lei->qerr($m);
+ } else {
+ $lei->qerr("# $tot matches");
+ }
}
- }
- $lei->start_mua if $start_mua;
- $lei->dclose;
+ $lei->start_mua if $l2m && !$l2m->lock_free;
+ $lei->dclose;
+ };
+ $lei->fail($@) if $@;
}
sub do_post_augment {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-15 15:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 15:52 [PATCH] lei q: guard query_done against die() 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).