summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-11-11 15:54:52 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-11-11 15:54:52 -0500
commitd1b22b252481134815b1d02d564b6b9622fe7b4b (patch)
tree2d88759a461226dd4f72928da0c815c83502c27f /IkiWiki.pm
parenteef8b966b366a11b69248d16f4f283d0dfbe3023 (diff)
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.pm19
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;
} #}}}