From: Mark Jason Dominus (陶敏修) Date: Sun, 30 Nov 2014 19:34:46 +0000 (-0500) Subject: in debug mode, issue a warning before waiting for a lock X-Git-Tag: 3.20150107~42 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/e2354943d7bca4e52fce923ff7709b7f84bd76e1?hp=cfbf8f07252b13143412413e753c3849efa5153c in debug mode, issue a warning before waiting for a lock --- 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; }