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-ASN: 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 D020D1F9F4 for ; Sat, 25 Sep 2021 05:49:45 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/3] lei2mail: augment_inprogress: guard against closed FDs Date: Sat, 25 Sep 2021 05:49:45 +0000 Message-Id: <20210925054945.12715-4-e@80x24.org> In-Reply-To: <20210925054945.12715-1-e@80x24.org> References: <20210925054945.12715-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I'm not sure what caused it, but $err was undef and caused print to fail, leading to an event loop error. Guard the timer with an eval and assume warn() can't trigger an event loop failure. --- lib/PublicInbox/LeiToMail.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/LeiToMail.pm b/lib/PublicInbox/LeiToMail.pm index ed609081b0a4..467b27bf275d 100644 --- a/lib/PublicInbox/LeiToMail.pm +++ b/lib/PublicInbox/LeiToMail.pm @@ -789,12 +789,15 @@ sub wq_atexit_child { # runs on a 1s timer in lei-daemon sub augment_inprogress { my ($err, $opt, $dst, $au_noted) = @_; - $$au_noted++ and return; - print $err '# '.($opt->{'import-before'} ? - "importing non-external contents of $dst" : ( - ($opt->{dedupe} // 'content') ne 'none') ? - "scanning old contents of $dst for dedupe" : - "removing old contents of $dst")." ...\n"; + eval { + return if $$au_noted++ || !$err || !defined(fileno($err)); + print $err '# '.($opt->{'import-before'} ? + "importing non-external contents of $dst" : ( + ($opt->{dedupe} // 'content') ne 'none') ? + "scanning old contents of $dst for dedupe" : + "removing old contents of $dst")." ...\n"; + }; + warn "E: $@" if $@; } # called in top-level lei-daemon when LeiAuth is done