Topic: Conflict with identical scripts loaded into independent virtual hosts

Hello,

We have been running a single instance of a large Perl application under
Apache/mod_perl for a long time. We would like to run the same script (but each with
different configuration data) under different virtual hosts.


According to all of the documentation I've read, a script running under a
virtual host should be loaded into a package name derived from the virtual host.
This is supposed to be the default behavior. So the scripts SHOULD be independent.
We've even tried to set $Apache::Registry::NameWithVirtualHost = 1; in the startup.pl
file without success.


We are seeing one virtual host script calling subroutines in another virtual
host script. Not what we expected. In the case of our large application we see that
many subroutines are prefixed with the virtual host name when we do a trace.


        I have isolated the code that does this into half a dozen line. I've 
created
two versions of the trivial script to demonstrate the problem.

Test1:
-------
package fred;

use CGI qw(:standard);
use strict;

sub test_sub {
     CGI::p("Host1 subroutine");
}

print CGI::header, start_html (), CGI::p("Host1 parent"), &test_sub(), end_html();
-------


Test 2:
--------

package fred;

use CGI qw(:standard);
use strict;

sub test_sub {
    CGI::p("Host2 subroutine");
}

print CGI::header, start_html (), CGI::p("Host2 parent") , &test_sub(), end_html();

1;

From the httpd.conf file: (I'll include the configuration for one of the scripts)

  Inside one of our virtual host sections:

    RewriteRule ^/Test(.*) /tmp/test/test1.pl

    <Directory /tmp/test>
        SetHandler perl-script
        PerlHandler Apache::Registry
        Options ExecCGI
        Order deny,allow
        deny from all
        PerlSendHeader Off
    </Directory>

Producing Problem Behavior:

To demonstrate the behavior I first restart Apache. The first time you make requests
to a fresh httpd either script works fine. Once started, subsequent requests made to the
first virtual host appear to override the subroutines from the second virtual host
such that subsequent calls to the second virtual host script end up calling the
subroutine from the first virtual host. Sometimes it's the other way around.
This should not happen according to what I've read.


At first we see normal behavior: [Output copied from browser]

Host1 parent
Host1 subroutine

Host2 parent
Host2 subroutine

Then the virtual hosts get a little confused...

Host1 parent
Host2 subroutine

...

Host2 parent
Host1 subroutine


Sometimes it is easy to reproduce the flaky behavior above, and other times it takes
quite a few reloads to do so. If you need additional information please feel free to
contact me.


Any help is greatly appreciated.

David

------------------------------------------------
Software:
        Apache: 1.3.33
        mod_perl: 1.29


> /usr/local/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
Platform:
osname=solaris, osvers=2.9, archname=sun4-solaris
uname='sunos library27 5.9 generic_117171-05 sun4u sparc sunw,sun-fire-v240 '
config_args='-de'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='3.3.2', gccosandvers='solaris2.9'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib '
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


 Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under solaris
  Compiled at Oct 27 2004 10:53:27
  @INC:
    /usr/local/lib/perl5/5.8.5/sun4-solaris
    /usr/local/lib/perl5/5.8.5
    /usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.8.5
    /usr/local/lib/perl5/site_perl
    .




Reply via email to