in debug mode, issue a warning before waiting for a lock

master
Mark Jason Dominus (陶敏修) 2014-11-30 14:34:46 -05:00 committed by Amitai Schlair
parent cfbf8f0725
commit e2354943d7
1 changed files with 6 additions and 2 deletions

View 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;
}