On Thursday, August 19, 2010 09:12:41 Mark Risher wrote:
> I am trying to load a configuration file into a hash during my
> PerlChildInitHandler and then access the values from PerlResponseHandler.
> However, even though the process number is the same, it seems that
> variables changed during the child_init() call revert back to their
> default values when handler() gets called.
>
> The basic scenario is:
>
>
> package StartupLog;
>
> # the variable I'm testing
> my $sticky = 0;
>
> sub child_init {
> $sticky = 1;
> return 0;
> }
>
> sub handler {
> warn __PACKAGE__ . " sticky = $sticky\n"; ### always says "0" but
> should say "1"
> return 0;
> }
> 1;
>
> I've been tearing my hair out for hours on this one. Is this something
> intrinsic to mod_perl that I'm overlooking? I can't find any good
> examples of loading a config during the PerlChildInit, even though that
> seems like the best time for me to load it.
The only thing where mod_perl may stay in the way here is if you use somehow a
different interpreter for child_init than for handler. Do you use a threaded
MPM, e.g. windows? Do you use the +Parent PerlOption in a VHost?
Otherwise, the bug is somewhere in your code. Try to answer a few questions:
1) is the child_init handler called?
2) are handler, child_init and $sticky in the same scope? Forgot "use strict"?
Try to print \$sticky in both handlers.
3) perhaps your intend was to use a package variable (the warning you print
out makes me think so)
Torsten Förtsch
--
Need professional modperl support? Hire me! (http://foertsch.name)
Like fantasy? http://kabatinte.net