RE: mod_perl bug (mod_perl 1.21; Apache 1.3.9).

2000-01-26 Thread Doug MacEachern

On Wed, 19 Jan 2000, John Hughes wrote:

  what happens if you preload Apache::Registry in httpd.conf:
 
  PerlModule Apache::Registry
 
 Didn't try that.  But code examination seems to imply that it would have
 no effect.
 
 1. Apache::Registry gets run, so:
 
   unless (defined $Apache::Registry::NameWithVirtualHost) {
   $Apache::Registry::NameWithVirtualHost = 1;
   }
 
Now NameWithVirtualHost is 1.
 
 2. a non-virtualhost request is received so perl_handler in mod_perl.c does:
 
 if((nwvh = ApachePerlRun_name_with_virtualhost())) {
 if(!r-server-is_virtual) {
 SAVESPTR(nwvh);
 sv_setiv(nwvh, 0);
 }
 }
 
now NameWithVirtualHost is 0.
 
and it stays zero forever.
 
 On reflection my fix is over the top - it has the effect of overriding
 the value of NameWithVirtualHost set by the user.
 
 I don't think perl_handler should be changing NameWithVirtualHost *AT ALL*,
 that should be left up to the user, with a default in Registry.pm.

it used to be that way, but moved to perl_handler because it's a quicker
check in C, and multiple modules (besides Apache::Registry) need this
logic.

 I attach patches to do that.  They work for me.

thanks.  I'll revisit this soon.
 
 One last query, what about ApachePerlRun_namespace in PerlRunXS.xs, that
 seems to think that the mere existence of the variable NameWithVirtualHost
 implies that names should be modified with the virtualhost.  It doesn't
 check the *VALUE* of the variable:

that's okay, I don't think anybody is using PerlRunXS, I'd be surprised if
it still works at all.  if there's to be a xs/c version ala PerlRunXS,
it's put off until modperl-2.0



RE: mod_perl bug (mod_perl 1.21; Apache 1.3.9).

2000-01-19 Thread John Hughes

 what happens if you preload Apache::Registry in httpd.conf:

 PerlModule Apache::Registry

Didn't try that.  But code examination seems to imply that it would have
no effect.

1. Apache::Registry gets run, so:

unless (defined $Apache::Registry::NameWithVirtualHost) {
$Apache::Registry::NameWithVirtualHost = 1;
}

   Now NameWithVirtualHost is 1.

2. a non-virtualhost request is received so perl_handler in mod_perl.c does:

if((nwvh = ApachePerlRun_name_with_virtualhost())) {
if(!r-server-is_virtual) {
SAVESPTR(nwvh);
sv_setiv(nwvh, 0);
}
}

   now NameWithVirtualHost is 0.

   and it stays zero forever.

On reflection my fix is over the top - it has the effect of overriding
the value of NameWithVirtualHost set by the user.

I don't think perl_handler should be changing NameWithVirtualHost *AT ALL*,
that should be left up to the user, with a default in Registry.pm.

I attach patches to do that.  They work for me.

One last query, what about ApachePerlRun_namespace in PerlRunXS.xs, that
seems to think that the mere existence of the variable NameWithVirtualHost
implies that names should be modified with the virtualhost.  It doesn't
check the *VALUE* of the variable:

#ifndef ApachePerlRun_name_with_virtualhost
#define ApachePerlRun_name_with_virtualhost() \
perl_get_sv("Apache::Registry::NameWithVirtualHost", FALSE)
#endif

SV *ApachePerlRun_namespace(request_rec *r, char *root)
{
...
if(r-server-is_virtual  ApachePerlRun_name_with_virtualhost()) {
uri = pstrcat(r-pool, r-server-server_hostname, uri, NULL);
uri_len += strlen(r-server-server_hostname);
}

--
John Hughes [EMAIL PROTECTED],
CalvaEDI SA.Tel: +33-1-4313-3131
66 rue du Moulin de la Pointe,  Fax: +33-1-4313-3139
75013 PARIS.


--- mod_perl-1.21/src/modules/perl/mod_perl.c.orig  Thu Jul  1 20:17:38 1999
+++ mod_perl-1.21/src/modules/perl/mod_perl.c   Wed Jan 19 11:35:12 2000
@@ -751,7 +751,6 @@
 dPPDIR;
 dPPREQ;
 dTHR;
-SV *nwvh = Nullsv;
 
 (void)acquire_mutex(mod_perl_mutex);
 
@@ -772,13 +771,6 @@
 (int)sv_count, (int)sv_objcount));
 ENTER;
 SAVETMPS;
-
-if((nwvh = ApachePerlRun_name_with_virtualhost())) {
-   if(!r-server-is_virtual) {
-   SAVESPTR(nwvh);
-   sv_setiv(nwvh, 0);
-   }
-}
 
 if (siggv) {
save_hptr(GvHV(siggv)); 
--- mod_perl-1.21/lib/Apache/Registry.pm.orig   Wed Jan 13 03:56:34 1999
+++ mod_perl-1.21/lib/Apache/Registry.pmWed Jan 19 11:38:05 2000
@@ -62,7 +62,7 @@
substr($uri, 0, length($uri)-length($r-path_info)) :
$uri;
 
-   if($Apache::Registry::NameWithVirtualHost) {
+   if($Apache::Registry::NameWithVirtualHost  $r-server-is_virtual) {
my $name = $r-get_server_name;
$script_name = join "", $name, $script_name if $name;
}