From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E72821F405 for ; Tue, 30 Jan 2024 10:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1706610327; bh=yZiVCklAHUi4MxDC/bcaT8o19x4mPpIU3+eiSvNj9+M=; h=From:To:Subject:Date:From; b=PXuOdSGncFUGjTrtayL+7aeoDQ2SPphOnq3yCJGZurC9Zw64jwe0WQ5T0wPu55s/W 31kSgD/WQCxC18/f9thNH8qt9g8Wh2bVj/5z9NHOdgeHZ2mmgdeWi0YNdw4sFxyCqG nU8IBAcsEFAFBLRkZ82m9v6ixROdG3BspJkGiYeE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_to_mail: improve SIGPIPE handling Date: Tue, 30 Jan 2024 10:20:49 +0000 Message-ID: <20240130102049.61382-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I can't reproduce this in t/lei-sigpipe.t with GIANT_INBOX_DIR. In real-world usage, having a large `lei q -f text ...' output piped to a pager and killing the pager prematurely could trigger: non-fatal error from PublicInbox::LeiToMail $?=256 messages in my terminal. This is because $self->{lei} was becoming undefined in the process cleanup process of git_to_mail. So flip the cleanup logic around and unconditionally check for Git::cleanup state to bail out early. With this change, the `non-fatal error ...' message no longer appears when I stop reading results early. --- lib/PublicInbox/LeiToMail.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index 008da52e..9197bb44 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -136,11 +136,9 @@ sub eml2mboxcl2 { sub git_to_mail { # git->cat_async callback my ($bref, $oid, $type, $size, $smsg) = @_; $type // return; # called by PublicInbox::Git::close - my $self = delete $smsg->{l2m}; - if (!defined($self)) { - return if $PublicInbox::Git::in_cleanup; - croak "BUG: no l2m (type=$type)"; - } + return if $PublicInbox::Git::in_cleanup; + my $self = delete $smsg->{l2m} // croak "BUG: no l2m (type=$type)"; + $self->{lei} // croak "BUG: no {lei} (type=$type)"; eval { if ($type eq 'missing' && ($bref = $self->{-lms_rw}->local_blob($oid, 1))) {