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 883B01F66F; Sun, 15 Nov 2020 23:20:17 +0000 (UTC) Date: Sun, 15 Nov 2020 23:20:17 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH v2] searchidx: check for graceful shutdown in log2stack Message-ID: <20201115232017.GA13149@dcvr> References: <20201115091613.25173-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201115091613.25173-1-e@80x24.org> List-Id: The initial "git log" invocation for a git epoch can be time consuming, so check for graceful shutdown at each line to ensure timely shutdowns and avoid SSD/HDD wear. --- v2: much simpler than v1, since log2stack and prepare_stack callers already understand a `undef' return value. lib/PublicInbox/SearchIdx.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 90d8c8b3..6ff2cf94 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -753,6 +753,7 @@ sub log2stack ($$$) { $range); my ($at, $ct, $stk, $cmt); while (<$fh>) { + return if $sync->{quit}; if (/\A([0-9]+)-([0-9]+)-($OID)$/o) { ($at, $ct, $cmt) = ($1 + 0, $2 + 0, $3); $stk //= PublicInbox::IdxStack->new($cmt);