about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-31 22:28:19 -1000
committerEric Wong <e@80x24.org>2021-02-01 11:38:13 +0000
commita480fead6bf174973289e326425dc82f609414e0 (patch)
tree10d5b1fe94c3ba6b32a28641f2e3bf5833ddf9f2
parent9b023d00e86f3990de8767ba5d9d00207febf3c0 (diff)
downloadpublic-inbox-a480fead6bf174973289e326425dc82f609414e0.tar.gz
This may be needed to avoid warnings/errors when
operating in single process mode in the future.
-rw-r--r--lib/PublicInbox/SharedKV.pm9
1 files changed, 8 insertions, 1 deletions
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;