about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiXSearch.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/LeiXSearch.pm')
-rw-r--r--lib/PublicInbox/LeiXSearch.pm17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index d4f34733..43dedd10 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -22,6 +22,7 @@ use PublicInbox::ContentHash qw(git_sha);
 use POSIX qw(strftime);
 use autodie qw(close open read seek truncate);
 use PublicInbox::Syscall qw($F_SETPIPE_SZ);
+use PublicInbox::OnDestroy;
 
 sub new {
         my ($class) = @_;
@@ -363,7 +364,7 @@ print STDERR $_;
                                                 $self, $lei, $each_smsg);
                 };
                 my ($exc, $code) = ($@, $?);
-                $lei->sto_done_request if delete($self->{-sto_imported});
+                $lei->sto_barrier_request if delete($self->{-sto_imported});
                 die "E: $exc" if $exc && !$code;
                 my $nr = delete $lei->{-nr_remote_eml} // 0;
                 if (!$code) { # don't update if no results, maybe MTA is down
@@ -399,7 +400,7 @@ sub query_done { # EOF callback for main daemon
         delete $lei->{lxs};
         ($lei->{opt}->{'mail-sync'} && !$lei->{sto}) and
                 warn "BUG: {sto} missing with --mail-sync";
-        $lei->sto_done_request;
+        $lei->sto_barrier_request;
         $lei->{ovv}->ovv_end($lei);
         if ($l2m) { # close() calls LeiToMail reap_compress
                 $l2m->finish_output($lei);
@@ -428,11 +429,9 @@ sub query_done { # EOF callback for main daemon
         $lei->dclose;
 }
 
-sub do_post_augment {
+sub post_augment_done { # via on_destroy in top-level lei-daemon
         my ($lei) = @_;
-        my $l2m = $lei->{l2m} or return; # client disconnected
-        eval { $l2m->post_augment($lei) };
-        my $err = $@;
+        my $err = delete $lei->{post_augment_err};
         if ($err) {
                 if (my $lxs = delete $lei->{lxs}) {
                         $lxs->wq_kill(-POSIX::SIGTERM());
@@ -447,6 +446,12 @@ sub do_post_augment {
         close(delete $lei->{au_done}); # trigger wait_startq if start_mua didn't
 }
 
+sub do_post_augment {
+        my ($lei) = @_;
+        my $l2m = $lei->{l2m} or return; # client disconnected
+        $l2m->post_augment($lei, on_destroy(\&post_augment_done, $lei));
+}
+
 sub incr_post_augment { # called whenever an l2m shard finishes augment
         my ($lei) = @_;
         my $l2m = $lei->{l2m} or return; # client disconnected