sub need_xapian ($) { $_[0]->{indexlevel} =~ $xapianlevels }
-sub _xdb_release {
+sub idx_release {
my ($self, $wake) = @_;
if (need_xapian($self)) {
my $xdb = delete $self->{xdb} or croak 'not acquired';
1;
}
-sub _xdb_acquire {
+sub idx_acquire {
my ($self) = @_;
my $flag;
my $dir = $self->xdir;
$git->cleanup;
delete $self->{txn};
$xdb->cancel_transaction if $xdb;
- $xdb = _xdb_release($self);
+ $xdb = idx_release($self);
# ensure we leak no FDs to "git log" with Xapian <= 1.2
my $range = $lx eq '' ? $tip : "$lx..$tip";
$self->{over}->rethread_done($opts) if $newest; # all done
$self->commit_txn_lazy;
$git->cleanup;
- $xdb = _xdb_release($self, $nr);
+ $xdb = idx_release($self, $nr);
# let another process do some work...
$pr->("indexed $nr/$self->{ntodo}\n") if $pr && $nr;
if (!$newest) { # more to come
$? == 0 or die ref($self)." pid:$pid exited with: $?";
} else {
die "transaction in progress $self\n" if $self->{txn};
- $self->_xdb_release if $self->{xdb};
+ idx_release($self) if $self->{xdb};
}
}
sub _begin_txn {
my ($self) = @_;
- my $xdb = $self->{xdb} || $self->_xdb_acquire;
+ my $xdb = $self->{xdb} || idx_acquire($self);
$self->{over}->begin_lazy if $self->{over};
$xdb->begin_transaction if $xdb;
$self->{txn} = 1;
my $ibx = $v2w->{ibx};
my $self = $class->SUPER::new($ibx, 1, $shard);
# create the DB before forking:
- $self->_xdb_acquire;
+ $self->idx_acquire;
$self->set_indexlevel;
- $self->_xdb_release;
+ $self->idx_release;
$self->spawn_worker($v2w, $shard) if $v2w->{parallel};
$self;
}
if ($line eq "commit\n") {
$self->commit_txn_lazy;
} elsif ($line eq "close\n") {
- $self->_xdb_release;
+ $self->idx_release;
} elsif ($line eq "barrier\n") {
$self->commit_txn_lazy;
# no need to lock < 512 bytes is atomic under POSIX
my $im = $ibx->importer(0);
if ($V == 1) {
my $sidx = PublicInbox::SearchIdx->new($ibx, 1);
- $sidx->_xdb_acquire;
+ $sidx->idx_acquire;
$sidx->set_indexlevel;
- $sidx->_xdb_release; # allow watching on lockfile
+ $sidx->idx_release; # allow watching on lockfile
}
my $pi_config = PublicInbox::Config->new(\<<EOF);
publicinbox.inbox-idle.inboxdir=$inboxdir