From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 495271F670 for ; Wed, 26 Aug 2020 08:17:43 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/5] over: rename ->disconnect to ->dbh_close Date: Wed, 26 Aug 2020 08:17:39 +0000 Message-Id: <20200826081742.16642-3-e@yhbt.net> In-Reply-To: <20200826081742.16642-1-e@yhbt.net> References: <20200826081742.16642-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Since we got rid of over->connect, `disconnect' no longer pairs with it. So name it after the `close(2)' syscall it ultimately issues. --- lib/PublicInbox/Over.pm | 4 ++-- lib/PublicInbox/OverIdx.pm | 6 +++--- lib/PublicInbox/V2Writable.pm | 4 ++-- t/over.t | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index 0ebc8003..a2cf9f21 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -72,7 +72,7 @@ sub new { bless { filename => $f }, $class; } -sub disconnect { +sub dbh_close { my ($self) = @_; if (my $dbh = delete $self->{dbh}) { delete $self->{-get_art}; @@ -328,7 +328,7 @@ sub check_inodes { my $st = pack('dd', $st[0], $st[1]); # don't actually reopen, just let {dbh} be recreated later - disconnect($self) if $st ne ($self->{st} // $st); + dbh_close($self) if $st ne ($self->{st} // $st); } else { warn "W: stat $f: $!\n"; } diff --git a/lib/PublicInbox/OverIdx.pm b/lib/PublicInbox/OverIdx.pm index c521464a..512c5f46 100644 --- a/lib/PublicInbox/OverIdx.pm +++ b/lib/PublicInbox/OverIdx.pm @@ -455,10 +455,10 @@ sub rollback_lazy { $self->{dbh}->rollback; } -sub disconnect { +sub dbh_close { my ($self) = @_; die "in transaction" if $self->{txn}; - $self->SUPER::disconnect; + $self->SUPER::dbh_close; } sub create { @@ -470,7 +470,7 @@ sub create { } # create the DB: PublicInbox::Over::dbh($self); - $self->disconnect; + $self->dbh_close; } sub rethread_prepare { diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index c926446c..f2288904 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -679,8 +679,8 @@ sub done { $err .= "shard close: $@\n" if $@; } } - eval { $self->{over}->disconnect }; - $err .= "over disconnect: $@\n" if $@; + eval { $self->{over}->dbh_close }; + $err .= "over close: $@\n" if $@; delete $self->{bnote}; my $nbytes = $self->{total_bytes}; $self->{total_bytes} = 0; diff --git a/t/over.t b/t/over.t index 6c4c8ee6..41c13872 100644 --- a/t/over.t +++ b/t/over.t @@ -23,7 +23,7 @@ $y = $over->sid('hello-WORLD'); is($y, $x+1, 'sid increases'); is($over->sid('hello-world'), $x, 'idempotent'); ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly'); -$over->disconnect; +$over->dbh_close; $over = PublicInbox::Over->new("$tmpdir/over.sqlite3"); ok($over->dbh->{ReadOnly}, 'Over is ReadOnly');