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-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 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 179281F9FF for ; Thu, 25 Mar 2021 04:20:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/10] lei: janky $PATH2CFG garbage collection Date: Thu, 25 Mar 2021 06:20:18 +0200 Message-Id: <20210325042026.11270-3-e@80x24.org> In-Reply-To: <20210325042026.11270-1-e@80x24.org> References: <20210325042026.11270-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We need to rely on this to keep our config cache (and lei_store pipes) under control with tests each creating a new config and directory. --- lib/PublicInbox/LEI.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index e5211764..d534f1d0 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -705,6 +705,12 @@ sub _lei_cfg ($;$) { File::Spec->canonpath($cfg->{'leistore.dir'})) { $cfg->{-lei_store} = $sto; } + if (scalar(keys %PATH2CFG) > 5) { + # FIXME: use inotify/EVFILT_VNODE to detect unlinked configs + for my $k (keys %PATH2CFG) { + delete($PATH2CFG{$k}) unless -f $k + } + } $self->{cfg} = $PATH2CFG{$f} = $cfg; }