You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by E R <pc...@gmail.com> on 2009/11/16 23:10:59 UTC
code in sections executed twice in same process?
Hi -
I am using mod-perl 1.3.41 with perl 5.8.9.
The only perl I have in my config file is:
<Perl>
warn "This is a <perl> section in process $$ at time @{[time]}\n";
sleep(5);
warn "Done sleeping\n";
</Perl>
When I start it up in single process mode (-X), I'll something like
this on stderr (to the console):
This is a <perl> section in process 25597 at time 1258408992
Done sleeping
And also in the error log I'll see:
This is a <perl> section in process 25597 at time 1258408998
Done sleeping
The pids will be the same, but the times will be different (about 5
secs. apart.)
Is this "normal", and what can I do so that the code in <Perl>
sections is only executed once in the parent process?
Thanks,
ER
Re: code in sections executed twice in same process?
Posted by Adam Prime <ad...@utoronto.ca>.
E R wrote:
> The <perl> sections don't seem to be executed in the children.
use a PerlChildInitHandler if you want to run code in the children.
> Is there a way to determine which pass you are in?
>
> For large mod_perl apps, is there a way to avoid loading your code in twice?
>
> Note I am using mod_perl 1.3.41.
In mp1, use $Apache::Server::Starting, and $Apache::Server::ReStarting.
see here:
http://perl.apache.org/docs/1.0/guide/config.html#Apache_Restarts_Twice_On_Start
Adam
Re: code in sections executed twice in same process?
Posted by E R <pc...@gmail.com>.
The <perl> sections don't seem to be executed in the children.
Is there a way to determine which pass you are in?
For large mod_perl apps, is there a way to avoid loading your code in twice?
Note I am using mod_perl 1.3.41.
Thanks,
ER
On Mon, Nov 16, 2009 at 4:41 PM, André Warnier <aw...@ice-sa.com> wrote:
> E R wrote:
> ...
>>
>> Is this "normal", and what can I do so that the code in <Perl>
>> sections is only executed once in the parent process?
>>
> I believe it is "normal", in the sense that Apache actually parses its
> configuration at least twice : one time "just for checking", then it throws
> everything away and parses it a second time "for real".
>
> Then it will even (probably) run your section again, each time it starts a
> new child process.
>
> You probably really want to read the following 2 pages :
> http://perl.apache.org/docs/2.0/user/handlers/server.html
> http://perl.apache.org/docs/2.0/user/config/custom.html
>
>
Re: code in sections executed twice in same process?
Posted by André Warnier <aw...@ice-sa.com>.
E R wrote:
...
>
> Is this "normal", and what can I do so that the code in <Perl>
> sections is only executed once in the parent process?
>
I believe it is "normal", in the sense that Apache actually parses its
configuration at least twice : one time "just for checking", then it
throws everything away and parses it a second time "for real".
Then it will even (probably) run your section again, each time it starts
a new child process.
You probably really want to read the following 2 pages :
http://perl.apache.org/docs/2.0/user/handlers/server.html
http://perl.apache.org/docs/2.0/user/config/custom.html