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 9A0201F66F for ; Sun, 15 Nov 2020 09:16:13 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] searchidx: check for graceful shutdown in log2stack Date: Sun, 15 Nov 2020 09:16:13 +0000 Message-Id: <20201115091613.25173-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. --- lib/PublicInbox/SearchIdx.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index 90d8c8b3..1466b88b 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>) { + last if $sync->{quit}; if (/\A([0-9]+)-([0-9]+)-($OID)$/o) { ($at, $ct, $cmt) = ($1 + 0, $2 + 0, $3); $stk //= PublicInbox::IdxStack->new($cmt); @@ -775,7 +776,9 @@ sub log2stack ($$$) { $stk->push_rec('m', $at, $ct, $oid, $cmt); } } - close $fh or die "git log failed: \$?=$?"; + unless (close $fh) { + die "git log failed: \$?=$?" unless $sync->{quit}; + } $stk //= PublicInbox::IdxStack->new; $stk->read_prepare; }