From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5C6121F51E for ; Sat, 1 Oct 2022 00:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1664582865; bh=z457IxGlMxEJhRAJfwF7FuRSQy8bYKDSs2CO03zAM3c=; h=From:To:Subject:Date:From; b=aJ1sTjlJrcgQ2OZvUmM50/cWYl8iKUIpio862pHCbB49FUJdUqRZOepuJFnePDUka mtkaonW3tsjJTVsXWvlBCo+nBav5jQ9K8+iIBnYqbND1oCP//slSll0lZeKWBMgS/e 93gzazZmgs0fuXZ3jz8DDdoYh18j/ZrDnzaQMZNA= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] git_async_cat: automatically cleanup temporary gits Date: Sat, 1 Oct 2022 00:07:45 +0000 Message-Id: <20221001000745.19836-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This prevents temporary directories and git processes from lingering around after WWW solver requests. --- lib/PublicInbox/GitAsyncCat.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/PublicInbox/GitAsyncCat.pm b/lib/PublicInbox/GitAsyncCat.pm index b32c2fd3..2d601542 100644 --- a/lib/PublicInbox/GitAsyncCat.pm +++ b/lib/PublicInbox/GitAsyncCat.pm @@ -45,6 +45,12 @@ sub event_step { } } +sub git_tmp_cleanup { + my ($git) = @_; + $git->cleanup(1) and + PublicInbox::DS::add_timer(3, \&git_tmp_cleanup, $git); +} + sub ibx_async_cat ($$$$) { my ($ibx, $oid, $cb, $arg) = @_; my $git = $ibx->{git} // $ibx->git; @@ -63,6 +69,8 @@ sub ibx_async_cat ($$$$) { $git->{async_cat} //= do { my $self = bless { git => $git }, __PACKAGE__; $git->{in}->blocking(0); + $git->{-tmp} and PublicInbox::DS::add_uniq_timer( + 3, \&git_tmp_cleanup, $git); $self->SUPER::new($git->{in}, EPOLLIN|EPOLLET); \undef; # this is a true ref() };