On Tue, 10 Jul 2001, Robin Berjon wrote:
> Hi,
>
> I've been looking around for a way for a <Perl> section (or code called from
> it, or perhaps even loaded through PerlModule) to know the current
> VirtualHost in which it is, at server startup (ie without a request object
> handy).
>
> Apache->server returns the main server object (or so it seems, that would
> appear to be logical) and I know that I can use $s->next to get a chain of
> server objects, but I can't seem to find a way in C or in Perl to know about
> the current server.
Apache->server will point to the current VirtualHost with this patch..
--- src/modules/perl/perl_config.c 2001/06/19 03:12:45 1.110
+++ src/modules/perl/perl_config.c 2001/07/11 02:46:32
@@ -1744,7 +1744,15 @@
ENTER_SAFE(parms->server, parms->pool);
MP_TRACE_g(mod_perl_dump_opmask());
- perl_eval_sv(code, G_DISCARD);
+
+ {
+ SV *server_sv = perl_get_sv("Apache::__SERVER", FALSE);
+ IV ptr = SvIVX(SvRV(server_sv));
+ SvIVX(SvRV(server_sv)) = (IV)parms->server;
+ perl_eval_sv(code, G_DISCARD);
+ SvIVX(SvRV(server_sv)) = (IV)ptr;
+ }
+
LEAVE_SAFE;
{