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.
debug("wiki is locked by another process, not aggregating");
exit 1;
}
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();
}
} #}}}
IkiWiki::unlockwiki();
}
} #}}}
error("rename $newfile: $!", $cleanup);
} #}}}
error("rename $newfile: $!", $cleanup);
} #}}}
-sub clearstate () { #{{{
- %feeds=();
- %guids=();
- $state_loaded=0;
-} #}}}
-
sub expire () { #{{{
foreach my $feed (values %feeds) {
next unless $feed->{expireage} || $feed->{expirecount};
sub expire () { #{{{
foreach my $feed (values %feeds) {
next unless $feed->{expireage} || $feed->{expirecount};
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)
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
-- Joey Hess <joeyh@debian.org> Fri, 11 Jan 2008 15:09:37 -0500