unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] lei_store_err: flush before disabling alarm
@ 2024-11-10 11:14 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-11-10 11:14 UTC (permalink / raw)
  To: meta

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 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/PublicInbox/LeiStoreErr.pm b/lib/PublicInbox/LeiStoreErr.pm
index c8bc72b6..14efa107 100644
--- a/lib/PublicInbox/LeiStoreErr.pm
+++ b/lib/PublicInbox/LeiStoreErr.pm
@@ -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;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-10 11:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-10 11:14 [PATCH] lei_store_err: flush before disabling alarm Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).