On Thu, Apr 29, 2010 at 4:39 AM, Tim Bunce <tim.bu...@pobox.com> wrote: > On Wed, Apr 28, 2010 at 11:25:14PM -0400, Adam Prime wrote: >> Maybe you could try doing the push_handler for the ChildExitHandler >> when the ChildInitHandler executes? Just a shot in the dark. > > Umm, but how to I get the ChildInitHandler handle to use the right perl > interpreter?
I just tried to setup a test case but I don't have perl configured with ithreads. Can you do something like this, since each vhost servername is tied to that perl intepreter? (warning, untested code) sub child_exit { my $vhost_servername = shift; my $s = Apache2::ServerUtil->server; return unless $s->hostname eq $vhost_servername; DB::_finish(); } $s->push_handlers(PerlChildExitHandler => \&child_exit($s->server_hostname ); > > Tim. > >> Adam >> >> Tim Bunce wrote: >> >This is proving to be tricky. >> > >> >If I load Devel::NYTProf::Apache[1] in the main part of httpd.conf then >> >I get a profile that includes all the activity *except* for any activity >> >in vhosts that use +Parent. >> > >> >If I load it inside the VirtualHost section then I get a profile of >> >activity within that vhost. Great. Except there's a problem... >> > >> >For a profile to be useful it must be terminated properly. Devel::NYTProf >> >does that using an END block. Devel::NYTProf::Apache does that using >> > >> > sub child_exit { DB::_finish() } >> > >> > my $s = Apache2::ServerUtil->server; >> > $s->push_handlers(PerlChildExitHandler => \&child_exit); >> > >> >That works fine normally, but doesn't work with PerlOptions +Parent. >> >I get an error: >> > [error] lookup of 'Devel::NYTProf::Apache::child_exit' failed >> > >> >I presume that's because the $s doesn't refer to the vhost "I'm in". >> >I can use $s->next (after require Apache2::ServerRec) to iterate over >> >the vhosts but I can't see a way to find "my" vhost. >> > >> >Is there one? >> > >> >What I'm looking for is some way for *a specific vhost perl interpreter* >> >to run code at PerlChildExitHandler *in that interpreter*. >> > >> >Any ideas? >> > >> >Tim. >> > >> >p.s. Simply adding END { DB::_finish() } to Devel::NYTProf::Apache gives >> >me a profile that ends during server initialization because the vhost >> >perl interpreter is initialized using perl_run() and PL_exit_flags |= >> >PERL_EXIT_DESTRUCT_END has not been set. So I've now set PL_exit_flags >> >via NYTProf and that's giving me a usable profile for my limited case. >> >I've not yet looked-into how to generalise that into code that's work in >> >normal (non +Parent) case. >> > >> >[1] >> >http://cpansearch.perl.org/src/TIMB/Devel-NYTProf-3.11/lib/Devel/NYTProf/Apache.pm >> >> >