summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-21 08:55:28 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-02-21 08:55:28 +0000
commitc60477228c6b4d5e00c7bdb3b895e9f30d00ea97 (patch)
tree03b0c2eceadcc57a732eca6a054dff92fbd4eb56 /IkiWiki.pm
parent24b83435061f94c6e203ed1b31b114b53ab8b8a3 (diff)
* Since the CGI had to drop the wiki lock to avoid deadlocking the
commit hook, it was possible for one CGI to race another one and "win" the commit of both their files. This race has been fixed by adding a new commitlock, which when locked by the CGI, disables the commit hook (except for commit mails). The CGI then takes care of the updates the commit hook would have done.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 40622a5be..c8d959edd 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -38,6 +38,7 @@ sub defaultconfig () { #{{{
wikiname => "wiki",
default_pageext => "mdwn",
cgi => 0,
+ post_commit => 0,
rcs => '',
notify => 0,
url => '',
@@ -601,7 +602,7 @@ sub lockwiki () { #{{{
}
open(WIKILOCK, ">$config{wikistatedir}/lockfile") ||
error ("cannot write to $config{wikistatedir}/lockfile: $!");
- if (! flock(WIKILOCK, 2 | 4)) {
+ if (! flock(WIKILOCK, 2 | 4)) { # LOCK_EX | LOCK_NB
debug("wiki seems to be locked, waiting for lock");
my $wait=600; # arbitrary, but don't hang forever to
# prevent process pileup
@@ -617,6 +618,29 @@ sub unlockwiki () { #{{{
close WIKILOCK;
} #}}}
+sub commit_hook_enabled () { #{{{
+ open(COMMITLOCK, "+>$config{wikistatedir}/commitlock") ||
+ error ("cannot write to $config{wikistatedir}/commitlock: $!");
+ if (! flock(WIKILOCK, 1 | 4)) { # LOCK_SH | LOCK_NB to test
+ close WIKILOCK;
+ return 0;
+ }
+ close WIKILOCK;
+ return 1;
+} #}}}
+
+sub disable_commit_hook () { #{{{
+ open(COMMITLOCK, ">$config{wikistatedir}/commitlock") ||
+ error ("cannot write to $config{wikistatedir}/commitlock: $!");
+ if (! flock(COMMITLOCK, 2)) { # LOCK_EX
+ error("failed to get commit lock");
+ }
+} #}}}
+
+sub enable_commit_hook () { #{{{
+ close COMMITLOCK;
+} #}}}
+
sub loadindex () { #{{{
open (IN, "$config{wikistatedir}/index") || return;
while (<IN>) {