about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-30 08:05:33 +0000
committerEric Wong <e@yhbt.net>2020-07-31 08:42:39 +0000
commitf60f934cfe1e7a06c853741fbabbbbe3a9a747a4 (patch)
tree668506fdaa881850256bb0f7d6c7b87eee7f436a
parentae6a9be7afc6902f9b8970b3656af241d6bc1d9f (diff)
downloadpublic-inbox-f60f934cfe1e7a06c853741fbabbbbe3a9a747a4.tar.gz
This ought to be useful for diagnosing bugs in -watch.
-rw-r--r--lib/PublicInbox/Lock.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/PublicInbox/Lock.pm b/lib/PublicInbox/Lock.pm
index c0d4d3b3..ca43682f 100644
--- a/lib/PublicInbox/Lock.pm
+++ b/lib/PublicInbox/Lock.pm
@@ -12,8 +12,9 @@ use Carp qw(croak);
 # PublicInbox::Import already has the lock on its own.
 sub lock_acquire {
         my ($self) = @_;
-        croak 'already locked' if $self->{lockfh};
-        my $lock_path = $self->{lock_path} or return;
+        my $lock_path = $self->{lock_path};
+        croak 'already locked '.($lock_path // '(undef)') if $self->{lockfh};
+        return unless defined($lock_path);
         sysopen(my $lockfh, $lock_path, O_WRONLY|O_CREAT) or
                 die "failed to open lock $lock_path: $!\n";
         flock($lockfh, LOCK_EX) or die "lock failed: $!\n";