+ return close($wikilock) if $wikilock;
+ return;
+} #}}}
+
+my $commitlock;
+
+sub commit_hook_enabled () { #{{{
+ open($commitlock, '+>', "$config{wikistatedir}/commitlock") ||
+ error("cannot write to $config{wikistatedir}/commitlock: $!");
+ if (! flock($commitlock, 1 | 4)) { # LOCK_SH | LOCK_NB to test
+ close($commitlock) || error("failed closing commitlock: $!");
+ return 0;
+ }
+ close($commitlock) || error("failed closing commitlock: $!");
+ 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");
+ }
+ return 1;
+} #}}}
+
+sub enable_commit_hook () { #{{{
+ return close($commitlock) if $commitlock;
+ return;