The problem: -----------------
When you're using prefork MPM, you try to create as many constant data-structures as possible before the children are being forked. Sometimes, these structures require updating during the lifetime of the server, but the updated information does not need to be available to all the currently running children. And/Or you don't want the server to be completely restarted for that. An example would be a blacklist of IP-numbers that you want to block, or indexes that only need updating if a new entry is added.
Note that the Perl code remains unchanged, it's just some data-structures (usually hashes and lists) that you want updated and distributed among newly created children.
The idea I has was this:
at compile time, a signal handler is installed:
package Foo our updatedat = 0; $SIG{123} = sub { $updatedat = time() };
and a Perl*Handler (PreConnection?) is installed. This handler should run _inside_ the parent before each request. It would conceptually go like this:
sub Foo::check_update {
return unless my $at = $updatedat; # return now unless something needs to be updated
# update data-structures
$updatedat = 0 if $updatedat == $at; # only reset flag if not set again in different second
}
Then:
any process, and this could be one of the Apache children, sends a signal 123 to the parent Apache process because it has updated the external copy of the data structure (e.g. it has added an IP number to the blacklist). When a new request comes in, the flag is checked and the internal data-structure is updated. And all new children after that, will automatically get this new, shared data.
Would this make sense in a prefork MPM (in a *nix environment, of course)?
Or are there better solutions to this "problem" ?
Liz
-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html