about summary refs log tree commit homepage
path: root/lib/PublicInbox/ExtSearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-11-07 10:56:59 +0000
committerEric Wong <e@80x24.org>2020-11-08 10:18:22 +0000
commit3ba7c9fa4a083c439e768882c571c2026a981ca5 (patch)
tree738620e8ce06c5461c0983625138b3396b4300fc /lib/PublicInbox/ExtSearchIdx.pm
parent5ed2573594258bd53c9ae8e1c1c517a0c8ba191f (diff)
downloadpublic-inbox-3ba7c9fa4a083c439e768882c571c2026a981ca5.tar.gz
Matching the behavior of git-fast-import(1), we'll allow a user
to send SIGUSR1 to checkpoint over.sqlite3 and Xapian.
Diffstat (limited to 'lib/PublicInbox/ExtSearchIdx.pm')
-rw-r--r--lib/PublicInbox/ExtSearchIdx.pm23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index 50342802..7aaf8291 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -284,16 +284,9 @@ sub last_commits {
 }
 
 sub _sync_inbox ($$$) {
-        my ($self, $opt, $ibx) = @_;
-        my $sync = {
-                need_checkpoint => \(my $bool = 0),
-                reindex => $opt->{reindex},
-                -opt => $opt,
-                self => $self,
-                ibx => $ibx,
-                nr => \(my $nr = 0),
-                -regen_fmt => "%u/?\n",
-        };
+        my ($self, $sync, $ibx) = @_;
+        $sync->{ibx} = $ibx;
+        $sync->{nr} = \(my $nr = 0);
         my $v = $ibx->version;
         my $ekey = $ibx->eidx_key;
         if ($v == 2) {
@@ -324,10 +317,18 @@ sub eidx_sync { # main entry point
         local $SIG{__WARN__} = sub {
                 $warn_cb->($self->{current_info}, ': ', @_);
         };
+        my $sync = {
+                need_checkpoint => \(my $need_checkpoint = 0),
+                reindex => $opt->{reindex},
+                -opt => $opt,
+                self => $self,
+                -regen_fmt => "%u/?\n",
+        };
+        local $SIG{USR1} = sub { $need_checkpoint = 1 };
 
         # don't use $_ here, it'll get clobbered by reindex_checkpoint
         for my $ibx (@{$self->{ibx_list}}) {
-                _sync_inbox($self, $opt, $ibx);
+                _sync_inbox($self, $sync, $ibx);
         }
 
         $self->{oidx}->rethread_done($opt);