From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 274F11F5AE; Thu, 30 Jul 2020 08:05:33 +0000 (UTC) Date: Thu, 30 Jul 2020 08:05:33 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lock: show failure path Message-ID: <20200730080533.GA8841@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: This ought to be useful for diagnosing bugs in -watch. --- Tracking down a problem in -watch with Maildirs... lib/PublicInbox/Lock.pm | 5 +++-- 1 file 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";