my ($len, $msgref) = @{$im->{last_object}};
$self->idx_init;
- my $num = $self->{all}->index_mm($mime);
+ my $num = $self->{all}->index_mm($mime, 1);
my $nparts = $self->{partitions};
my $part = $num % $nparts;
my $idx = $self->idx_part($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;
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;
}
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;