httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rasmus Lerdorf <ras...@apache.org>
Subject Re: How to change ap_document_root variable from a apache2 module ?
Date Fri, 31 Dec 2004 05:03:35 GMT
On Thu, 30 Dec 2004, Paul Querna wrote:
> Rasmus Lerdorf wrote:
> [snip]
> >>Hint: document root is a configuration value used *by default* in
> >>filename translation.  Any module can implement its own translation
> >>hook, but trying to change a core configuration value is not only
> >>utterly pointless (your module can use its own variables), it's
> >>working against the apache design, even in a non-threaded MPM.
> >
> >
> > Whether it is against the design or not, it is a useful thing to be able
> > to do.  And I fully realize that my module can do whatever it wants, but
> > other modules won't know about it unless I modify them.
>
> I agree this could be a useful 'feature'.  I believe in a new API for
> configuration, this should be taken into consideration. However, the
> current hack of overwriting the values of a CORE config struct is
> completely bogus.
>
> >
> > 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().

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 that I am hoping to see the richer and more flexible
Apache2 API address.

-Rasmus

Mime
View raw message