Dominique Quatravaux has earlier posted a test that was demonstrating a problem with non-threaded perls and anon-subs registered at the server startup. This has now been fixed. But it has also revealed another problem in threaded perl setup, which I'm not sure we can provide a solution for.

The test at the end of this email added to our test suite creates the following 
situation:

1) Apache2::ServerUtil->server->push_handlers(PerlFixupHandler => sub { 
&test_waz_zere });

adds an anonsub to the top-level stack of handlers.

2) when a vhost starts with PerlOptions +Parent set, it doesn't clone the 
parent perl. So it will never be able to see the anonsub.

3) But when we do merging of the handlers stack the vhost inherits the 
PerlFixupHandler entry from the top-level server, which now points nowhere.

4) As a result, anything running in that vhost, gets:

 can't find ANONSUB's 'anon1' entry.

(at least it doesn't crush ;)

In our test suite it happens with all tests running inside vhosts w/ 
PerlOptions +Parent

The only solution I can think of is may be not to merge at all the handlers of 
the parent and vhost if the latter defines: PerlOptions +Parent.

or of course we could have gone back to serialization of the anonsub and then its 
recompilation, which we had before, but which was limping and it was replaced with 
anonsub "namisation" trick (which makes anonsub a named sub).

and Dominique's test:

package TestHooks::inlined_handlers_server_wide;

# this test exercises Apache handlers as anonymous subs, installed
# using Apache->server->push_handlers() at mod_perl initialization
# time.
# Previously there was a refcounting bug there, similar to the
# one described in inlined_handlers.pm

use strict;
use warnings FATAL => 'all';

use Apache2::RequestIO ();
use Apache2::ServerUtil ();
use Apache2::Const -compile => qw(OK DECLINED);

sub test_waz_zere {
   my ($r) = @_;
   $r->notes->set("test_waz_zere", 1);
   Apache2::Const::DECLINED;
}

BEGIN {
## This works (non-inlined handler):
# Apache2->server->push_handlers(PerlFixupHandler => \&test_waz_zere );
## This did not work as of Subversion r159573:
Apache2::ServerUtil->server->push_handlers(PerlFixupHandler => sub { &test_waz_zere });
}


sub handler {
   my $r = shift;

   $r->print("1..1\n");
   $r->print($r->notes->get("test_waz_zere") ? "ok 1\n" :
            "not ok 1\n");
   Apache2::Const::OK;
}

1;
__DATA__
<NoAutoConfig>
 <Perl >
 </Perl>
   PerlModule TestHooks::inlined_handlers_server_wide
 <Location /TestHooks__inlined_handlers_server_wide>
     SetHandler modperl
     PerlResponseHandler TestHooks::inlined_handlers_server_wide
 </Location>
</NoAutoConfig>

--
__________________________________________________________________
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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to