From e2354943d7bca4e52fce923ff7709b7f84bd76e1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mark=20Jason=20Dominus=20=28=E9=99=B6=E6=95=8F=E4=BF=AE=29?= Date: Sun, 30 Nov 2014 14:34:46 -0500 Subject: [PATCH 1/1] in debug mode, issue a warning before waiting for a lock --- IkiWiki.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 03f058ef7..a8e2865be 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -5,6 +5,7 @@ package IkiWiki; use warnings; use strict; use Encode; +use Fcntl q{:flock}; use URI::Escape q{uri_escape_utf8}; use POSIX (); use Storable; @@ -1813,8 +1814,11 @@ sub lockwiki () { } open($wikilock, '>', "$config{wikistatedir}/lockfile") || error ("cannot write to $config{wikistatedir}/lockfile: $!"); - if (! flock($wikilock, 2)) { # LOCK_EX - error("failed to get lock"); + if (! flock($wikilock, LOCK_EX | LOCK_NB)) { + debug("failed to get lock; waiting..."); + if (! flock($wikilock, LOCK_EX)) { + error("failed to get lock"); + } } return 1; } -- 2.39.5