about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/LEI.pm11
-rw-r--r--lib/PublicInbox/LeiXSearch.pm6
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index af39f8af..b00be1a1 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -631,6 +631,7 @@ sub pkt_op_pair {
 
 sub incr {
         my $lei = shift;
+        $lei->{incr_pid} = $$ if @_;
         while (my ($f, $n) = splice(@_, 0, 2)) { $lei->{$f} += $n }
 }
 
@@ -1399,10 +1400,12 @@ sub busy { 1 } # prevent daemon-shutdown if client is connected
 # can immediately reread it
 sub DESTROY {
         my ($self) = @_;
-        for my $k (sort(grep(/\A-nr_/, keys %$self))) {
-                my $nr = $self->{$k};
-                substr($k, 0, length('-nr_'), '');
-                $self->child_error(0, "$nr $k messages");
+        if (defined($self->{incr_pid}) && $self->{incr_pid} == $$) {
+                for my $k (sort(grep(/\A-nr_/, keys %$self))) {
+                        my $nr = $self->{$k};
+                        substr($k, 0, length('-nr_'), '');
+                        $self->child_error(0, "$nr $k messages");
+                }
         }
         $self->{1}->autoflush(1) if $self->{1};
         stop_pager($self);
diff --git a/lib/PublicInbox/LeiXSearch.pm b/lib/PublicInbox/LeiXSearch.pm
index 2a4af3e7..d83a403c 100644
--- a/lib/PublicInbox/LeiXSearch.pm
+++ b/lib/PublicInbox/LeiXSearch.pm
@@ -419,12 +419,12 @@ Error closing $lei->{ovv}->{dst}: \$!=$! \$?=$?
                         delete $l2m->{mbl}; # drop dotlock
                 }
         }
+        my $nr_w = delete($lei->{-nr_write}) // 0;
+        my $nr_dup = (delete($lei->{-nr_seen}) // 0) - $nr_w;
         if ($lei->{-progress}) {
                 my $tot = $lei->{-mset_total} // 0;
-                my $nr_w = delete($lei->{-nr_write}) // 0;
-                my $d = (delete($lei->{-nr_seen}) // 0) - $nr_w;
                 my $x = "$tot matches";
-                $x .= ", $d duplicates" if $d;
+                $x .= ", $nr_dup duplicates" if $nr_dup;
                 if ($l2m) {
                         my $m = "# $nr_w written to " .
                                 "$lei->{ovv}->{dst} ($x)";