]> Sergey Matveev's repositories - public-inbox.git/commitdiff
sharedkv: release {dbh} before rmtree
authorEric Wong <e@80x24.org>
Mon, 1 Feb 2021 08:28:19 +0000 (22:28 -1000)
committerEric Wong <e@80x24.org>
Mon, 1 Feb 2021 11:38:13 +0000 (11:38 +0000)
This may be needed to avoid warnings/errors when
operating in single process mode in the future.

lib/PublicInbox/SharedKV.pm

index 94f2429fdda2eaf51b3c378b5bd4c383bec43b8b..f5d09cc14dcfe3022539be322b53c77daad93701 100644 (file)
@@ -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;