+ my $next = {};
+ for my $ibx (values %$CLEANUP) {
+ my $again;
+ foreach my $f (qw(mm search over)) {
+ delete $ibx->{$f} if SvREFCNT($ibx->{$f}) == 1;
+ }
+ my $expire = time - 60;
+ if (my $git = $ibx->{git}) {
+ $again = $git->cleanup($expire);
+ }
+ if (my $gits = $ibx->{-repo_objs}) {
+ foreach my $git (@$gits) {
+ $again = 1 if $git->cleanup($expire);
+ }
+ }
+ $again ||= !!($ibx->{over} || $ibx->{mm} || $ibx->{search});
+ $next->{"$ibx"} = $ibx if $again;
+ }
+ $CLEANUP = $next;
+}
+
+sub _cleanup_later ($) {
+ my ($self) = @_;
+ return if $cleanup_broken;
+ return unless PublicInbox::EvCleanup::enabled();
+ $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
+ $CLEANUP->{"$self"} = $self;