until the wiki is building and already locked, unless it's aggregating.
When aggregating, it does not wait for the lock if it cannot get it, and
instead exits, to prevent aggregating processes from piling up.
return "<a href=\"$config{url}\">$config{wikiname}</a>";
} #}}}
return "<a href=\"$config{url}\">$config{wikiname}</a>";
} #}}}
+sub lockwiki (;$) { #{{{
+ my $wait=@_ ? shift : 1;
# 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}) {
# 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}) {
open(WIKILOCK, ">$config{wikistatedir}/lockfile") ||
error ("cannot write to $config{wikistatedir}/lockfile: $!");
if (! flock(WIKILOCK, 2 | 4)) { # LOCK_EX | LOCK_NB
open(WIKILOCK, ">$config{wikistatedir}/lockfile") ||
error ("cannot write to $config{wikistatedir}/lockfile: $!");
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
- for (1..$wait) {
- return if flock(WIKILOCK, 2 | 4);
- sleep 1;
+ 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 {
+ debug("wiki is locked");
+ return 0;
- error("wiki is locked; waited $wait seconds without lock being freed (possible stuck process or stale lock?)");
} #}}}
sub unlockwiki () { #{{{
} #}}}
sub unlockwiki () { #{{{
} #}}}
sub checkconfig () { #{{{
} #}}}
sub checkconfig () { #{{{
- my $nolock=($config{post_commit} && ! IkiWiki::commit_hook_enabled());
- IkiWiki::lockwiki() unless $nolock;
- loadstate();
- if ($config{aggregate} && ! $nolock) {
+ if ($config{aggregate} && ! ($config{post_commit} &&
+ IkiWiki::commit_hook_enabled())) {
+ # don't wait for the lock
+ IkiWiki::lockwiki(0) || exit 1;
+
+ loadstate();
IkiWiki::loadindex();
aggregate();
expire();
savestate();
IkiWiki::loadindex();
aggregate();
expire();
savestate();
+
+ IkiWiki::unlockwiki();
- IkiWiki::unlockwiki() unless $nolock;
} #}}}
sub filter (@) { #{{{
my %params=@_;
my $page=$params{page};
} #}}}
sub filter (@) { #{{{
my %params=@_;
my $page=$params{page};
+ loadstate(); # if not already loaded
# Mark all feeds originating on this page as removable;
# preprocess will unmark those that still exist.
remove_feeds($page);
# Mark all feeds originating on this page as removable;
# preprocess will unmark those that still exist.
remove_feeds($page);
+ return if $state_loaded;
if (-e "$config{wikistatedir}/aggregate") {
open (IN, "$config{wikistatedir}/aggregate" ||
die "$config{wikistatedir}/aggregate: $!");
if (-e "$config{wikistatedir}/aggregate") {
open (IN, "$config{wikistatedir}/aggregate" ||
die "$config{wikistatedir}/aggregate: $!");
+ikiwiki (2.2) UNRELEASED; urgency=low
+
+ * Change the aggregate plugin's locking strategy. Now it defers loading state
+ until the wiki is building and already locked, unless it's aggregating.
+ When aggregating, it does not wait for the lock if it cannot get it, and
+ instead exits, to prevent aggregating processes from piling up.
+
+ -- Joey Hess <joeyh@debian.org> Sun, 20 May 2007 22:23:09 -0400
+
ikiwiki (2.1) unstable; urgency=low
[ Joey Hess ]
ikiwiki (2.1) unstable; urgency=low
[ Joey Hess ]
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-05-19 19:33-0400\n"
+"POT-Creation-Date: 2007-05-20 22:48-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:62
+#: ../IkiWiki/Plugin/aggregate.pm:66
#, perl-format
msgid "missing %s parameter"
msgstr ""
#, perl-format
msgid "missing %s parameter"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:90
+#: ../IkiWiki/Plugin/aggregate.pm:94
msgid "new feed"
msgstr ""
msgid "new feed"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:104
+#: ../IkiWiki/Plugin/aggregate.pm:108
-#: ../IkiWiki/Plugin/aggregate.pm:106
+#: ../IkiWiki/Plugin/aggregate.pm:110
-#: ../IkiWiki/Plugin/aggregate.pm:212
+#: ../IkiWiki/Plugin/aggregate.pm:220
#, perl-format
msgid "expiring %s (%s days old)"
msgstr ""
#, perl-format
msgid "expiring %s (%s days old)"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:219
+#: ../IkiWiki/Plugin/aggregate.pm:227
#, perl-format
msgid "expiring %s"
msgstr ""
#, perl-format
msgid "expiring %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:242
+#: ../IkiWiki/Plugin/aggregate.pm:250
#, perl-format
msgid "processed ok at %s"
msgstr ""
#, perl-format
msgid "processed ok at %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:247
+#: ../IkiWiki/Plugin/aggregate.pm:255
#, perl-format
msgid "checking feed %s ..."
msgstr ""
#, perl-format
msgid "checking feed %s ..."
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:252
+#: ../IkiWiki/Plugin/aggregate.pm:260
#, perl-format
msgid "could not find feed at %s"
msgstr ""
#, perl-format
msgid "could not find feed at %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:267
+#: ../IkiWiki/Plugin/aggregate.pm:275
msgid "feed not found"
msgstr ""
msgid "feed not found"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:278
+#: ../IkiWiki/Plugin/aggregate.pm:286
#, perl-format
msgid "(invalid UTF-8 stripped from feed)"
msgstr ""
#, perl-format
msgid "(invalid UTF-8 stripped from feed)"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:283
+#: ../IkiWiki/Plugin/aggregate.pm:291
msgid "feed crashed XML::Feed!"
msgstr ""
msgid "feed crashed XML::Feed!"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:356
+#: ../IkiWiki/Plugin/aggregate.pm:364
#, perl-format
msgid "creating new page %s"
msgstr ""
#, perl-format
msgid "creating new page %s"
msgstr ""