From 770604494e1054ada8d9e3960e4a6c7e82a09ad5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 1 Oct 2021 09:54:43 +0000 Subject: inbox: keep DB handles if git processes are live Having git processes outlive DB handles is likely to hurt from a fragmentation perspective if the DB handle needs to be recreated immediately due to a git->cat_async callback. So only unref DB handles when we're sure there's no live git users left, otherwise check the inodes. We'll also avoid needless localization checks in git->cleanup and make the return value more obvious since the pid fields are unconditionally deleted nowadays. --- lib/PublicInbox/Git.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 97c39aad..77783000 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -399,16 +399,16 @@ sub async_wait_all ($) { # returns true if there are pending "git cat-file" processes sub cleanup { my ($self, $lazy) = @_; - local $in_cleanup = 1; return 1 if $lazy && (scalar(@{$self->{inflight_c} // []}) || scalar(@{$self->{inflight} // []})); + local $in_cleanup = 1; delete $self->{async_cat}; async_wait_all($self); delete $self->{inflight}; delete $self->{inflight_c}; _destroy($self, qw(cat_rbuf in out pid)); _destroy($self, qw(chk_rbuf in_c out_c pid_c err_c)); - defined($self->{pid}) || defined($self->{pid_c}); + undef; } # assuming a well-maintained repo, this should be a somewhat -- cgit v1.2.3-24-ge0c7