]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Lock.pm
nntpd+imapd: detect replaced over.sqlite3
[public-inbox.git] / lib / PublicInbox / Lock.pm
index ca6b33f26ed011bbc43648a1fa84e918b856330b..693a37949a651f7935df09d6c58a785dc2322140 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # Base class for per-inbox locking
@@ -24,6 +24,13 @@ sub lock_release {
        my ($self) = @_;
        return unless $self->{lock_path};
        my $lockfh = delete $self->{lockfh} or croak 'not locked';
+
+       # NetBSD 8.1 and OpenBSD 6.5 (and maybe other versions/*BSDs) lack
+       # NOTE_CLOSE_WRITE from FreeBSD 11+, so trigger NOTE_WRITE, instead.
+       # We also need to change the ctime on Linux systems w/o inotify
+       if ($^O ne 'linux' || !eval { require Linux::Inotify2; 1 }) {
+               syswrite($lockfh, '.');
+       }
        flock($lockfh, LOCK_UN) or die "unlock failed: $!\n";
        close $lockfh or die "close failed: $!\n";
 }