X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FV2Writable.pm;h=c4368cccc8502616ab8c4c536720d7c17106f596;hb=c4aa293b2320feb805c5afeaa373f608e5bc8618;hp=269b028f5373a9fb1e99ed7c2b8166c438c6d111;hpb=126e7c54da66ff58e20e76879decc91a075eeba1;p=public-inbox.git diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 269b028f..c4368ccc 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -50,6 +50,7 @@ sub new { } $nparts = nproc() if ($nparts == 0); + $v2ibx = PublicInbox::InboxWritable->new($v2ibx); my $self = { -inbox => $v2ibx, im => undef, # PublicInbox::Import @@ -137,7 +138,7 @@ sub num_for { warn "<$mid> reused for mismatched content\n"; # try the rest of the mids - foreach my $i (1..$#$mids) { + for(my $i = $#$mids; $i >= 1; $i--) { my $m = $mids->[$i]; $num = $self->{skel}->{mm}->mid_insert($m); if (defined $num) { @@ -193,20 +194,23 @@ sub idx_init { # frequently activated. delete $ibx->{$_} foreach (qw(git mm search)); - $self->lock_acquire; + $ibx->umask_prepare; + $ibx->with_umask(sub { + $self->lock_acquire; - # first time initialization, first we create the skeleton pipe: - my $skel = $self->{skel} = PublicInbox::SearchIdxSkeleton->new($self); + # first time initialization, first we create the skeleton pipe: + my $skel = PublicInbox::SearchIdxSkeleton->new($self); + $self->{skel} = $skel; - # need to create all parts before initializing msgmap FD - my $max = $self->{partitions} - 1; - my $idx = $self->{idx_parts} = []; - for my $i (0..$max) { - push @$idx, PublicInbox::SearchIdxPart->new($self, $i, $skel); - } + # need to create all parts before initializing msgmap FD + my $max = $self->{partitions} - 1; + @{$self->{idx_parts}} = map { + PublicInbox::SearchIdxPart->new($self, $_, $skel); + } (0..$max); - # Now that all subprocesses are up, we can open the FD for SQLite: - $skel->_msgmap_init->{dbh}->begin_work; + # Now that all subprocesses are up, we can open the FD for SQLite: + $skel->_msgmap_init->{dbh}->begin_work; + }); } sub purge_oids {