]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
in debug mode, issue a warning before waiting for a lock
authorMark Jason Dominus (陶敏修) <mjd@plover.com>
Sun, 30 Nov 2014 19:34:46 +0000 (14:34 -0500)
committerAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>
Tue, 2 Dec 2014 15:37:09 +0000 (10:37 -0500)
IkiWiki.pm

index 03f058ef7fdeaf708fe2ef0540b433e4d174a907..a8e2865be46e77725e8309d5fa67805ffe3bbc18 100644 (file)
@@ -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;
 }