From f49d6a9ac8ff542c625e909798ef0947df45f34e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 13 Jan 2021 19:06:24 -1200 Subject: lei: q: lock stdout on overview output Most writes to stdout aren't atomic and we need locking to prevent workers from interleaving and corrupting JSON output. The one case stdout won't require locking is if it's pointed to a regular file with O_APPEND; as POSIX O_APPEND semantics guarantees atomicity. --- lib/PublicInbox/Lock.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/PublicInbox/Lock.pm') diff --git a/lib/PublicInbox/Lock.pm b/lib/PublicInbox/Lock.pm index 2c5ebf27..bb213de4 100644 --- a/lib/PublicInbox/Lock.pm +++ b/lib/PublicInbox/Lock.pm @@ -37,7 +37,7 @@ sub lock_release { # caller must use return value sub lock_for_scope { my ($self, @single_pid) = @_; - $self->lock_acquire; + lock_acquire($self) or return; # lock_path not set PublicInbox::OnDestroy->new(@single_pid, \&lock_release, $self); } -- cgit v1.2.3-24-ge0c7