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 A16831FFAF for ; Mon, 1 Feb 2021 08:28:34 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 07/21] sharedkv: release {dbh} before rmtree Date: Sun, 31 Jan 2021 22:28:19 -1000 Message-Id: <20210201082833.3293-8-e@80x24.org> In-Reply-To: <20210201082833.3293-1-e@80x24.org> References: <20210201082833.3293-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This may be needed to avoid warnings/errors when operating in single process mode in the future. --- lib/PublicInbox/SharedKV.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/SharedKV.pm b/lib/PublicInbox/SharedKV.pm index 94f2429f..f5d09cc1 100644 --- a/lib/PublicInbox/SharedKV.pm +++ b/lib/PublicInbox/SharedKV.pm @@ -145,8 +145,15 @@ SELECT COUNT(k) FROM kv sub DESTROY { my ($self) = @_; + delete $self->{dbh}; my $dir = delete $self->{"tmp$$.$self"} or return; - rmtree($dir); + my $tries = 0; + do { + $! = 0; + eval { rmtree($dir) }; + } while ($@ && $!{ENOENT} && $tries++ < 5); + warn "error removing $dir: $@" if $@; + warn "Took $tries tries to remove $dir\n" if $tries; } 1;