]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: rename _xdb_{acquire,release} => idx_
authorEric Wong <e@yhbt.net>
Fri, 24 Jul 2020 05:56:00 +0000 (05:56 +0000)
committerEric Wong <e@yhbt.net>
Sat, 25 Jul 2020 20:48:18 +0000 (20:48 +0000)
The "xdb" prefix was inaccurate since it's used by
indexlevel=basic, which is Xapian-free.  The '_' (underscore)
prefix was also wrong for a method which is called across
package boundaries.

lib/PublicInbox/SearchIdx.pm
lib/PublicInbox/SearchIdxShard.pm
t/inbox_idle.t
t/search.t

index 2d53b2d034de2d5d02a11a990e63f62820ccf6a6..89c716793278bbbd1baf781832c46d291cbc5d5b 100644 (file)
@@ -77,7 +77,7 @@ sub new {
 
 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';
@@ -101,7 +101,7 @@ sub load_xapian_writable () {
        1;
 }
 
-sub _xdb_acquire {
+sub idx_acquire {
        my ($self) = @_;
        my $flag;
        my $dir = $self->xdir;
@@ -735,7 +735,7 @@ sub _index_sync {
                $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";
@@ -766,7 +766,7 @@ sub _index_sync {
                $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
@@ -805,7 +805,7 @@ sub remote_close {
                $? == 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};
        }
 }
 
@@ -821,7 +821,7 @@ sub remote_remove {
 
 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;
index fd34e487bc6065f6d1a5d5d6623637cf04fbd025..cb79f3dc9dfcb26499232a61beb0ffa778ec0a07 100644 (file)
@@ -15,9 +15,9 @@ sub new {
        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;
 }
@@ -56,7 +56,7 @@ sub shard_worker_loop ($$$$$) {
                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
index f754e0fcc4fea508faf048af107bc463a96f8a36..61287200d9bbe65f493c1b66ad50befa23c76355 100644 (file)
@@ -28,9 +28,9 @@ for my $V (1, 2) {
        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
index aa6f94bf348c39c874a2b90bca4a81a459d3072a..a75d944c32e9a1bf7a1e448072ba88d9772cc2ed 100644 (file)
@@ -21,8 +21,8 @@ ok($@, "exception raised on non-existent DB");
 
 my $rw = PublicInbox::SearchIdx->new($ibx, 1);
 $ibx->with_umask(sub {
-       $rw->_xdb_acquire;
-       $rw->_xdb_release;
+       $rw->idx_acquire;
+       $rw->idx_release;
 });
 $rw = undef;
 my $ro = PublicInbox::Search->new($ibx);