diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-11-11 15:54:52 -0500 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-11-11 15:54:52 -0500 |
commit | d1b22b252481134815b1d02d564b6b9622fe7b4b (patch) | |
tree | 2d88759a461226dd4f72928da0c815c83502c27f /IkiWiki.pm | |
parent | eef8b966b366a11b69248d16f4f283d0dfbe3023 (diff) | |
download | ikiwiki-d1b22b252481134815b1d02d564b6b9622fe7b4b.tar ikiwiki-d1b22b252481134815b1d02d564b6b9622fe7b4b.tar.gz |
lockwiki changes
* Stop busy-waiting in lockwiki, as this could delay ikiwiki from waking up
for up to one second. The bailout code is no longer needed.
* Remove support for unused optional wait parameter from lockwiki.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index dc9b66344..d949566d8 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1280,8 +1280,7 @@ sub indexlink () { #{{{ my $wikilock; -sub lockwiki (;$) { #{{{ - my $wait=@_ ? shift : 1; +sub lockwiki () { #{{{ # Take an exclusive lock on the wiki to prevent multiple concurrent # run issues. The lock will be dropped on program exit. if (! -d $config{wikistatedir}) { @@ -1289,20 +1288,8 @@ sub lockwiki (;$) { #{{{ } open($wikilock, '>', "$config{wikistatedir}/lockfile") || error ("cannot write to $config{wikistatedir}/lockfile: $!"); - if (! flock($wikilock, 2 | 4)) { # LOCK_EX | LOCK_NB - if ($wait) { - debug("wiki seems to be locked, waiting for lock"); - my $wait=600; # arbitrary, but don't hang forever to - # prevent process pileup - for (1..$wait) { - return if flock($wikilock, 2 | 4); - sleep 1; - } - error("wiki is locked; waited $wait seconds without lock being freed (possible stuck process or stale lock?)"); - } - else { - return 0; - } + if (! flock($wikilock, 2)) { # LOCK_EX + error("failed to get lock"); } return 1; } #}}} |