Stas Bekman wrote:
a=SERVER_CREATE(); b=SERVER_CREATE(); RegulateDatabase(a, ...); global_init(b); global_init(c);
I have no idea where 'c' is coming from--like I said, I've instrumented {SERVER,DIR}_{CREATE,MERGE}, which I think should cover everything.
PostConfig is called twice, because of the server startup:
http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_Phases_Demonstration_Module
Right...I figured I could probably handle that by setting a flag variable somewhere, or something of the sort.
Why are the PostConfig handlers being given config objects with different addresses, though?
...hmm. It looks like they're being handed different server objects: global_init server: Apache::Server=SCALAR(0x8caded0) global_init server: Apache::Server=SCALAR(0x8c059e0)
Because the second time it's a totally different perl. The perl that was used during the startup is no more during the restart.
Okay, this is starting to beg a question: why is PostConfig called twice? What does each call represent?
You probably need to read the section at the URL quoted above. If it's still not clear, please tell us what.
Why is it only called once for an 'apachectl -k restart'?
See the URL above. 'apachectl -k start' doing start and immediately restart.
And perhaps the question I should've asked to start with: if I need to fork off one background process for the entire Apache server, what handler should I do so in?
Any phase before child_init is fine. Though you will have to deal with restart calling this action again.
In mod_perl 1 there were $Server::Starting, Server::ReStarting flags which you could check to decide whether to do something or not at the server startup. They aren't yet available in mp2, mostly due to the fact that they weren't available in the Apache API until recently, and from what Geoff has mentioned it seems to be incomplete yet. Geoff, what's the current status of these query flags? I wasn't following cvs commits for quite some time. I've tried the new query flags added recently (you need cvs modperl and cvs apache to get them):
use Apache::MPM (); use Apache::Const -compile => qw(OK :mpmq);
my %states = ( +Apache::MPMQ_STARTING => 'starting', +Apache::MPMQ_RUNNING => 'running', );
sub post_config { my($conf_pool, $log_pool, $temp_pool, $s) = @_;
my $state = Apache::MPM->query(Apache::MPMQ_MPM_STATE); warn "Apache server is $states{$state}\n";
Apache::OK; }
But it prints 'starting' both on start and restart. I'd expect it to print running (or restarting). So I suppose these query flags don't give us the information we are after.
If nothing else works we will need to use the apr_pool user data trick and provide flag variables similar to mp1.
So for now, Brent, please use some flag (e.g. lock file) to decide whether you've already forked the process.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html