summaryrefslogtreecommitdiff
path: root/IkiWiki
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
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')
-rw-r--r--IkiWiki/CGI.pm65
-rw-r--r--IkiWiki/Plugin/poll.pm14
-rw-r--r--IkiWiki/Setup/Standard.pm3
3 files changed, 43 insertions, 39 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index e23ef8afd..e62bcf477 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -513,6 +513,7 @@ sub cgi_editpage ($$) { #{{{
return;
}
+ my $conflict;
if ($config{rcs}) {
my $message="";
if (defined $form->field('comments') &&
@@ -523,44 +524,44 @@ sub cgi_editpage ($$) { #{{{
if ($newfile) {
rcs_add($file);
}
- # prevent deadlock with post-commit hook
- unlockwiki();
- # presumably the commit will trigger an update
- # of the wiki
- my $conflict=rcs_commit($file, $message,
+
+ # Prevent deadlock with post-commit hook by
+ # signaling to it that it should not try to
+ # do anything (except send commit mails).
+ disable_commit_hook();
+ $conflict=rcs_commit($file, $message,
$form->field("rcsinfo"),
$session->param("name"), $ENV{REMOTE_ADDR});
+ enable_commit_hook();
+ rcs_update();
+ }
- if (defined $conflict) {
- $form->field(name => "rcsinfo", value => rcs_prepedit($file),
- force => 1);
- $form->tmpl_param("page_conflict", 1);
- $form->field("editcontent", value => $conflict, force => 1);
- $form->field(name => "comments", value => $form->field('comments'), force => 1);
- $form->field("do", "edit)");
- $form->tmpl_param("page_select", 0);
- $form->field(name => "page", type => 'hidden');
- $form->field(name => "type", type => 'hidden');
- $form->title(sprintf(gettext("editing %s"), $page));
- print $form->render(submit => \@buttons);
- return;
- }
- else {
- # Make sure that the repo is up-to-date;
- # locking prevents the post-commit hook
- # from updating it.
- rcs_update();
- }
+ # Refresh even if there was a conflict, since other changes
+ # may have been committed while the post-commit hook was
+ # disabled.
+ require IkiWiki::Render;
+ refresh();
+ saveindex();
+
+ if (defined $conflict) {
+ $form->field(name => "rcsinfo", value => rcs_prepedit($file),
+ force => 1);
+ $form->tmpl_param("page_conflict", 1);
+ $form->field("editcontent", value => $conflict, force => 1);
+ $form->field(name => "comments", value => $form->field('comments'), force => 1);
+ $form->field("do", "edit)");
+ $form->tmpl_param("page_select", 0);
+ $form->field(name => "page", type => 'hidden');
+ $form->field(name => "type", type => 'hidden');
+ $form->title(sprintf(gettext("editing %s"), $page));
+ print $form->render(submit => \@buttons);
+ return;
}
else {
- require IkiWiki::Render;
- refresh();
- saveindex();
+ # The trailing question mark tries to avoid broken
+ # caches and get the most recent version of the page.
+ redirect($q, "$config{url}/".htmlpage($page)."?updated");
}
-
- # The trailing question mark tries to avoid broken
- # caches and get the most recent version of the page.
- redirect($q, "$config{url}/".htmlpage($page)."?updated");
}
} #}}}
diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm
index a3321a32e..4eae6a349 100644
--- a/IkiWiki/Plugin/poll.pm
+++ b/IkiWiki/Plugin/poll.pm
@@ -125,17 +125,17 @@ sub cgi ($) { #{{{
IkiWiki::cgi_savesession($session);
$oldchoice=$session->param($choice_param);
if ($config{rcs}) {
- # prevent deadlock with post-commit hook
- IkiWiki::unlockwiki();
+ disable_commit_hook();
IkiWiki::rcs_commit($pagesources{$page}, "poll vote ($choice)",
IkiWiki::rcs_prepedit($pagesources{$page}),
$session->param("name"), $ENV{REMOTE_ADDR});
+ enable_commit_hook();
+ rcs_update();
}
- else {
- require IkiWiki::Render;
- IkiWiki::refresh();
- IkiWiki::saveindex();
- }
+ require IkiWiki::Render;
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
+
# Need to set cookie in same http response that does the
# redir.
eval q{use CGI::Cookie};
diff --git a/IkiWiki/Setup/Standard.pm b/IkiWiki/Setup/Standard.pm
index 0c4272286..f3f7bae5a 100644
--- a/IkiWiki/Setup/Standard.pm
+++ b/IkiWiki/Setup/Standard.pm
@@ -36,6 +36,9 @@ sub setup_standard {
foreach my $wrapper (@wrappers) {
%config=(%startconfig, verbose => 0, %setup, %{$wrapper});
checkconfig();
+ if (! $config{cgi} && ! $config{post_commit}) {
+ $config{post_commit}=1;
+ }
gen_wrapper();
}
%config=(%startconfig);