From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 044901FEB3; Sat, 7 Jan 2017 02:12:33 +0000 (UTC) Date: Sat, 7 Jan 2017 02:12:32 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 10/9] inbox: properly register cleanup timer for git processes Message-ID: <20170107021232.GA18591@dcvr> References: <20170107014452.9657-1-e@80x24.org> <20170107014452.9657-6-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170107014452.9657-6-e@80x24.org> List-Id: 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 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index aa4e141..51ada0b 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -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; }; } -- EW