]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: check for graceful shutdown in log2stack
authorEric Wong <e@80x24.org>
Sun, 15 Nov 2020 23:20:17 +0000 (23:20 +0000)
committerEric Wong <e@80x24.org>
Sun, 15 Nov 2020 23:32:29 +0000 (23:32 +0000)
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

index 90d8c8b33db860f927fe9b4d120479f0181f2f21..6ff2cf947189617729c18194a21d1e23a6ed64c5 100644 (file)
@@ -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);