aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-24 17:22:39 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-24 17:22:39 -0500
commit4f872b563300e4a277cac3d7ea2a999bcf75d1ff (patch)
treef04b6ecf827625f1bcba5fa6ab92abb90eb65a1d
parent39ee5fb8c66335f7a0e602985de00608f3617cb7 (diff)
downloadikiwiki-4f872b563300e4a277cac3d7ea2a999bcf75d1ff.tar
ikiwiki-4f872b563300e4a277cac3d7ea2a999bcf75d1ff.tar.gz
* aggregate: Fork a child process to handle the aggregation. This simplifies
the code, since that process can change internal state as needed, and it will automatically be cleaned up for the parent process, which proceeds to render the changes.
-rw-r--r--IkiWiki/Plugin/aggregate.pm33
-rw-r--r--debian/changelog4
2 files changed, 23 insertions, 14 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 0da527f25..09ea59029 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -37,14 +37,25 @@ sub checkconfig () { #{{{
debug("wiki is locked by another process, not aggregating");
exit 1;
}
-
- loadstate();
- IkiWiki::loadindex();
- aggregate();
- expire();
- savestate();
- clearstate();
-
+
+ # Fork a child process to handle the aggregation.
+ # The parent process will then handle building the result.
+ # This avoids messy code to clear state accumulated while
+ # aggregating.
+ defined(my $pid = fork) or error("Can’t fork: $!");
+ if (! $pid) {
+ loadstate();
+ IkiWiki::loadindex();
+ aggregate();
+ expire();
+ savestate();
+ exit 0;
+ }
+ waitpid($pid,0);
+ if ($?) {
+ error "aggregation failed with code $?";
+ }
+
IkiWiki::unlockwiki();
}
} #}}}
@@ -211,12 +222,6 @@ sub savestate () { #{{{
error("rename $newfile: $!", $cleanup);
} #}}}
-sub clearstate () { #{{{
- %feeds=();
- %guids=();
- $state_loaded=0;
-} #}}}
-
sub expire () { #{{{
foreach my $feed (values %feeds) {
next unless $feed->{expireage} || $feed->{expirecount};
diff --git a/debian/changelog b/debian/changelog
index f5e0b242e..d2fed8767 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,10 @@ ikiwiki (2.21) UNRELEASED; urgency=low
those older versions too.
* aggregate: Don't let feeds set creation times for pages in the future.
* Add full parser for git diff-tree output (Brian Downing)
+ * aggregate: Fork a child process to handle the aggregation. This simplifies
+ the code, since that process can change internal state as needed, and
+ it will automatically be cleaned up for the parent process, which proceeds
+ to render the changes.
-- Joey Hess <joeyh@debian.org> Fri, 11 Jan 2008 15:09:37 -0500