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;
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/

Reply via email to