about summary refs log tree commit homepage
path: root/lib/PublicInbox/V2Writable.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/V2Writable.pm')
-rw-r--r--lib/PublicInbox/V2Writable.pm18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 29ed23ca..3451261e 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -84,9 +84,9 @@ sub idx_part {
 sub idx_init {
         my ($self) = @_;
         return if $self->{idx_parts};
-        # first time initialization:
-        my $all = $self->{all} =
-                PublicInbox::SearchIdxThread->new($self->{-inbox});
+
+        # first time initialization, first we create the threader pipe:
+        my $all = $self->{all} = PublicInbox::SearchIdxThread->new($self);
 
         # need to create all parts before initializing msgmap FD
         my $max = $self->{partitions} - 1;
@@ -94,6 +94,8 @@ sub idx_init {
         for my $i (0..$max) {
                 push @$idx, PublicInbox::SearchIdxPart->new($self, $i, $all);
         }
+
+        # Now that all subprocesses are up, we can open the FD for SQLite:
         $all->_msgmap_init->{dbh}->begin_work;
 }
 
@@ -242,4 +244,14 @@ sub lookup_content {
         undef # TODO
 }
 
+sub atfork_child {
+        my ($self) = @_;
+        if (my $parts = $self->{idx_parts}) {
+                $_->atfork_child foreach @$parts;
+        }
+        if (my $im = $self->{im}) {
+                $im->atfork_child;
+        }
+}
+
 1;