httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <ge...@modperlcookbook.org>
Subject Re: How to change ap_document_root variable from a apache2 module ?
Date Mon, 03 Jan 2005 20:36:09 GMT

>>>This can be done quite safely in Apache1, by the way.
>>
>>I don't believe it can. Code?
> 
> 
> Well, since you don't need to worry about thread safety as long as you set
> it on every request, or reset it after each request you are fine.
> Something like:
> 
>   foo->old = ap_document_root(r);
>   conf = ap_get_module_config(s->module_config, &core_module);
>   conf->ap_document_root = new;
>   ap_register_cleanup(r->pool, foo, my_cleanup, ap_null_cleanup);
> 
> Then set it back to foo->old in my_cleanup().

fwiw, we follow this exact logic in mod_perl for Apache 1.3 as well.

> 
> And yes, I agree it is a hack to change anything in the core_module on a
> per-request basis, but there are a lot of things that are very useful
> hacks in Apache1 

right.  IIRC the inability to formally manipulate DocumentRoot is one of the
things that prevents (or did prevent the last time I looked at it, which was
a while ago) mod_vhost_alias and mod_frontpage from playing nice together.

> that I am hoping to see the richer and more flexible
> Apache2 API address.

it would certainly be nice to do this, but there has always been a little
pushback in the past IIRC.  the main argument that I remember is the
"DocumentRoot is considered private to core" one, but I'm just not sure how
much I believe this - if it were really private we wouldn't offer read
access either.

does it make sense to perhaps code in an optional function (or somesuch) in
2.2 that core would use to override its own DocumentRoot on a per-request basis?

--Geoff

Mime
View raw message