]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei2mail: augment_inprogress: guard against closed FDs
authorEric Wong <e@80x24.org>
Sat, 25 Sep 2021 05:49:45 +0000 (05:49 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Sep 2021 08:53:45 +0000 (08:53 +0000)
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

index ed609081b0a4c5dde199a0b5f47ce39989c1a652..467b27bf275dbf14ae15a8b3f81bff530e2eaf9b 100644 (file)
@@ -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