about summary refs log tree commit homepage
path: root/lib/PublicInbox/Lock.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-01-13 19:06:24 -1200
committerEric Wong <e@80x24.org>2021-01-15 00:19:07 +0000
commitf49d6a9ac8ff542c625e909798ef0947df45f34e (patch)
treee0623d0650944220dfa324273ec927dd23c56901 /lib/PublicInbox/Lock.pm
parentc7b789a770bbe9bbc262af850d863dee4efe8371 (diff)
downloadpublic-inbox-f49d6a9ac8ff542c625e909798ef0947df45f34e.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/Lock.pm')
-rw-r--r--lib/PublicInbox/Lock.pm2
1 files changed, 1 insertions, 1 deletions
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);
 }