perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <>
Subject Re: [mp2 bug] push_handlers(PostConfig...) on vhost is silently ignored
Date Thu, 24 Nov 2005 20:50:37 GMT
Stas Bekman wrote:
> Philippe M. Chiasson wrote:
>> Stas Bekman wrote:
>>> Configuring PostConfig phase via push_handlers on the vhost server is
>>> silently ignored under mp2.
>>> For example a custom directive handler FooBar:
>>> sub FooBar {
>>>    my ($self, $parms, $arg) = @_;
>>>    my $s = $parms->server;
>>>    # XXX: calling it on the non-vhost server works
>>>    #Apache2::ServerUtil->server->push_handlers(
>>>    $s->push_handlers(
>>>        PerlPostConfigHandler => \&post_config);
>>>    ...
>>> See the attached tarball that reproduces the problem.
>>> I think the solution should be either change modperl_post_config_handler
>>> to iterate over vhosts or it should explode when a user tries to
>>> register the callback on a vhost server (but it'll affect the
>>> push_handlers run-time performance a bit), to handle the special case.
>> I've been looking over this issue, and I think that iterating over
>> vhosts does
>> sound tempting, but it would mean different behaviour than it's
>> related httpd
>> API.
> Another problem is that if you put PerlPostConfigHandler inside vhost in
> httpd.conf it does get run (via base server)
> The main problem is that you can't get hold of the correct vhost server
> object from within PerlPostConfigHandler (which does work when using a
> custom directive or with <perl> using your latest fix).

Yes, makes sense since these are always registered with the base server

>> I do not like the fact that a vhost-registered postconfig hook just
>> ends up
>> not running at all though.
>> I would avoid the overhead by carefull documentation
>> "PostConfig and OpenLog *must* be called on the main server !!!"
> But who reads the docs?

He, I know what you mean ;-)

> mod_perl has more than one problem on the
> startup where commands are silently ignored and real errors aren't
> preventing Apache from starting (and errors being silented).
> Since this is a startup and performance is a non-issue, may be some
> function pointer manipulation could do? I.e. during the startup it will
> use a heavier version and after child_init switch to the light one.
> Probably an overkill...

Possibly an overkill for this problem, but certainly an interesting approach
to think about with the many other things that behave differently at startup
vs. runtime. Could gain us some nice performance bonus.

>> I've quickly implemented this looping over vhosts, and the problem it
>> causes is
>> that handlers defined in the main server are being run over and over
>> for each
>> vhost ;-S
> That's because they aren't registered per-vhost, but altogether.

Yes, that's obviously why. So, what's the preferred solution ?

1. Just bitch at startup if you try and add PostConfig and OpenLog to a vhost
2. Make it work by:
  - Keeping track of what vhost these hooks are registered against
  - Execute them with that correct vhost

1. is easy, 2 is harder ;-)

Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

View raw message