]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
solver: schedule cleanup after synchronous git->check
authorEric Wong <e@80x24.org>
Tue, 28 Nov 2023 14:56:17 +0000 (14:56 +0000)
committerEric Wong <e@80x24.org>
Wed, 29 Nov 2023 02:13:19 +0000 (02:13 +0000)
We don't want hundreds of git cat-file processes for coderepos
lingering around.

lib/PublicInbox/Git.pm
lib/PublicInbox/SolverGit.pm

index fe8342100059b0082030c3388a642ce28704bdc8..7c6e15b7c870080003fad236c89a955d1bfb0145 100644 (file)
@@ -628,10 +628,15 @@ sub event_step {
        }
 }
 
+sub schedule_cleanup {
+       my ($self) = @_;
+       PublicInbox::DS::add_uniq_timer($self+0, 30, \&cleanup, $self, 1);
+}
+
 # idempotently registers with DS epoll/kqueue/select/poll
 sub watch_async ($) {
        my ($self) = @_;
-       PublicInbox::DS::add_uniq_timer($self+0, 30, \&cleanup, $self, 1);
+       schedule_cleanup($self);
        $self->{epwatch} //= do {
                $self->SUPER::new($self->{sock}, EPOLLIN);
                \undef;
index ba3c94cb89275282232aaf8e2d1215974d7e39b9..7cc101986e5828d157b0d065a6ed247a5a3773e2 100644 (file)
@@ -82,7 +82,10 @@ sub solve_existing ($$) {
        my $try = $want->{try_gits} //= [ @{$self->{gits}} ]; # array copy
        my $git = shift @$try or die 'BUG {try_gits} empty';
        my $oid_b = $want->{oid_b};
+
+       # can't use async_check due to last_check_err :<
        my ($oid_full, $type, $size) = $git->check($oid_b);
+       $git->schedule_cleanup if $self->{psgi_env}->{'pi-httpd.async'};
 
        if ($oid_b eq ($oid_full // '') || (defined($type) &&
                                (!$self->{have_hints} || $type eq 'blob'))) {