]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_store_err: flush before disabling alarm
authorEric Wong <e@80x24.org>
Sun, 10 Nov 2024 11:14:15 +0000 (11:14 +0000)
committerEric Wong <e@80x24.org>
Mon, 11 Nov 2024 08:03:10 +0000 (08:03 +0000)
We must flush the output to ensure the alarm works properly,
so the easiest way is to rely on IO::Handle::autoflush rather
than calling an explicit close() since the SIG{ALRM} handler
may close it.

lib/PublicInbox/LeiStoreErr.pm

index c8bc72b68a2ca8f3df95d660261afd3a1fb4c033..14efa107e80bee0c3ed2fea341b02fbd0764e330 100644 (file)
@@ -27,6 +27,7 @@ sub abort_err_wr { close($err_wr) if $err_wr; undef $err_wr }
 sub emit ($@) {
        my ($efh, @msg) = @_;
        open(local $err_wr, '>&', $efh); # fdopen(dup(fileno($efh)), "w")
+       $err_wr->autoflush(1);
        local $SIG{ALRM} = \&abort_err_wr;
        Time::HiRes::alarm(1.0, 0.1);
        my $ret = print $err_wr @msg;