]> Sergey Matveev's repositories - public-inbox.git/commitdiff
inbox: properly register cleanup timer for git processes
authorEric Wong <e@80x24.org>
Sat, 7 Jan 2017 02:10:23 +0000 (02:10 +0000)
committerEric Wong <e@80x24.org>
Sat, 7 Jan 2017 02:10:23 +0000 (02:10 +0000)
We still need to cleanup git processes occasionally, since
"git cat-file --batch" does not release old packs (and
git processes are fairly expensive).

For SQLite and Xapian file handles, they should be capable
of managing themselves without too much trouble, so lets
try keeping them for the lifetime of a process.

lib/PublicInbox/Inbox.pm

index aa4e141f6cfcd36a67bca71893a6363b8b0005c7..51ada0bc390458df9a992ff77ca934097293db60 100644 (file)
@@ -22,12 +22,6 @@ sub cleanup_task () {
        $CLEANUP = {};
 }
 
-sub _cleanup_later ($) {
-       my ($self) = @_;
-       $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
-       $CLEANUP->{"$self"} = $self;
-}
-
 sub _set_uint ($$$) {
        my ($opts, $field, $default) = @_;
        my $val = $opts->{$field};
@@ -76,6 +70,8 @@ sub git {
        $self->{git} ||= eval {
                my $g = PublicInbox::Git->new($self->{mainrepo});
                $g->{-httpbackend_limiter} = $self->{-httpbackend_limiter};
+               $cleanup_timer ||= PublicInbox::EvCleanup::later(*cleanup_task);
+               $CLEANUP->{"$self"} = $self;
                $g;
        };
 }