You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Zeev Suraski <bo...@netvision.net.il> on 1999/05/01 22:31:42 UTC

Module initialization and per-directory config directives

Hi,

One of the problems the PHP 3.0 Apache module had, was that httpd.conf
directives were being parsed before module startups.  Since PHP uses
various data structures to store values it reads from Apache directives
(among other sources), and since these data structures weren't being
initialized before Apache was calling the PHP's callback functions, we had
to change the callbacks so that they always call PHP's startup function
before going on.  Of course, we've put a flag inside that function so that
it won't actually initialize more than once, but still, each .conf or
.htaccess directive parsing resulted in an additional function call, and
that function call had to be written on the top of every handler. 

While cleaning mod_php3.c for PHP 4.0, I was wondering on whether this
behavior can be changed, or fixed in some way.  Is there no way to ensure
that the module's startup is run before its callbacks are called with
directive information? 

I realize that there's a good chance you can't simply move the module
startups to be called before the configuration parsing (for various
reasons), but if you can, or alternately, can provide an additional module
initialzation function that's guarenteed to be called before the
configuration parsing, it would make callbacks look cleaner and be more
efficient...

Zeev


-- 
-----------------------------------------------------
Zeev Suraski <ze...@zend.com>
For a PGP public key, finger bourbon@netvision.net.il



Re: Module initialization and per-directory config directives

Posted by Ben Hyde <bh...@pobox.com>.
Zeev Suraski <bo...@netvision.net.il> writes:

...
> directives were being parsed before module startups ...
> ...  the callbacks so that they always call PHP's startup function
> before going on.  ...

It is possible if you proposed a patch it would get in.

I think every significant module I've got or read does just
that.  Every configuration directive calls out to the module
begin init, and then latter when Apache calls the module so called
module init, it does he "end init".

There are two reasons why there is not a "begin init" call.

First it is a slightly delicate to design since you have
to decide what to do in all four (or more?) senarios.
 1. Directive reading during requests.
 2. Directive reading phase 1.
 3. Directive reading phase 2.
 4. Restart directive reading.

Second there developed during the last release a reluctance
to adding new callbacks.  The design for more hooks built
up, encryption export issues made the water muddy, API
stablity advocates spoke up, tempers flaired.  Ralf 
implemented EAPI to get them for his needs.  I did the
same, I suspect others did too.

 - ben