List Info

Thread: virtualhosts with same Docroots steal Request object and Session




virtualhosts with same Docroots steal Request object and Session
country flaguser name
Germany
2007-10-05 15:28:57
Dear list,
I have this scenario:
Two virtual servers ( A and B ) share the same
DocumentRoot,
due to the fact that every server needs some special
"global" variables,
each is set up with its own Perl interpreter.
The first Request to the page mypage.epl determinates which
server has 
the "right" Enviroment.
Subsequent Request to the same document from the other
server shows that 
not even the variable is "gone", but also the
Embperl-Request and 
therefore udat, mdat and fdat.

To make clear what happens:
httpd.conf:
MaxServers 1
<VirtualHost  12.34.56:8080>
    Servername A
    PerlOptions    +Parent
    PerlSwitches   -Mlib=/webserver/A/lib
    PerlRequire    /webserver/A/lib/startup.pl
    Embperl_Appname A-app
    Embperl_Options 270338
    Embperl_Cookie_Name "A_cookie"
    DocumentRoot /webservers/htdocs
</VirtualHost>
<VirtualHost  12.34.56:80>
    Servername B
    PerlOptions    +Parent
    PerlSwitches   -Mlib=/webserver/B/lib
    PerlRequire    /webserver/B/lib/startup.pl
    Embperl_Appname B-app
    Embperl_Options 270338
    Embperl_Cookie_Name "B_cookie"
    DocumentRoot /webservers/htdocs
</VirtualHost>

startup.pl:
use Some::Modul;
our $GLOBAL;
$GLOBAL = { key1 => A | B };

mypage.epl:
<html><pre>
outerTEXT
[*
my $r = shift;
print OUT "TEST:n";
print OUT Data:umper:umper(
$::GLOBAL );
print OUT Data:umper:umper
( $r );
*]
<pre></html>

If I access mypage.epl through server A
http://A/mypage.epl, I got
the following ( expected ) result:
outerTEXT
TEST:
$VAR1 = {
                    'key1' => A
                };

$VAR1 = bless( {}, 'Embperl::Req' );

If I call http://B/mypage.epl, I get :
outerTEXT

Not even the static "TEST" ist printed, neither
the expected "key1 => B"
Attempts to set $udat{'somekey} fail because "Can't
call method "init" 
on unblessed reference at 
/usr/lib/perl5/site_perl/5.8.5/Apache/SessionX.pm" and
in fact is $self 
in SessionX.pm undef.
Attemps to access $r->app fail, because of  "Can't
call method "app" on 
an undefined value".

If I force a recompile of the page and access it at first
from server B 
everything is the other way round.

I expected each virtual host to have a global variable
called $::GLOBAL 
and %udat and $r to behave "normal" because, the
not only have their own 
Perlinterpreters but also different Embperl_Appnames and
even the cookie 
name ist different, so that their should be IMHO no
interference.

What am I missing here?
Any hint is welcome.
thanks in advance


frank

-- 
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web: http://www.fotofinder.net/

Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky




------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
For additional commands, e-mail: embperl-helpperl.apache.org


Re: virtualhosts with same Docroots steal Request object and Session
country flaguser name
Germany
2007-10-05 15:48:22
I am very sorry,
I forgot to supply the credentials:
It is Embperl 2.2.0 with an
Apache 2.0.52 ( preforking )
Perl is 5.8.5
all that running under RedHat 3.4.6-3

-- 
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web: http://www.fotofinder.net/

Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky




------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
For additional commands, e-mail: embperl-helpperl.apache.org


RE: virtualhosts with same Docroots steal Request object and Session
user name
2007-10-07 06:44:58
Hi,

> I have this scenario:
> Two virtual servers ( A and B ) share the same
DocumentRoot, 
> due to the fact that every server needs some special
"global" 
> variables, each is set up with its own Perl
interpreter.
> The first Request to the page mypage.epl determinates
which 
> server has the "right" Enviroment.
> Subsequent Request to the same document from the other
server 
> shows that not even the variable is "gone",
but also the 
> Embperl-Request and therefore udat, mdat and fdat.
> 

I guess the problem is that Embperl is not aware of these
two Perl 
interpreters. There are some structures that are process
global inside 
of Embperl (even it is designed to support multiple
interpreteres and 
threads, it's not done yet).

I would suggest to just run two instances of Apache. Since
Perl is what 
takes up the memory, it will not make much difference to
have two Apache 
instance or having two Perl interpreter inside one Apache
instance (at 
least as long as the prefork mpm is used)

Gerald



> To make clear what happens:
> httpd.conf:
> MaxServers 1
> <VirtualHost  12.34.56:8080>
>     Servername A
>     PerlOptions    +Parent
>     PerlSwitches   -Mlib=/webserver/A/lib
>     PerlRequire    /webserver/A/lib/startup.pl
>     Embperl_Appname A-app
>     Embperl_Options 270338
>     Embperl_Cookie_Name "A_cookie"
>     DocumentRoot /webservers/htdocs
> </VirtualHost>
> <VirtualHost  12.34.56:80>
>     Servername B
>     PerlOptions    +Parent
>     PerlSwitches   -Mlib=/webserver/B/lib
>     PerlRequire    /webserver/B/lib/startup.pl
>     Embperl_Appname B-app
>     Embperl_Options 270338
>     Embperl_Cookie_Name "B_cookie"
>     DocumentRoot /webservers/htdocs
> </VirtualHost>
> 
> startup.pl:
> use Some::Modul;
> our $GLOBAL;
> $GLOBAL = { key1 => A | B };
> 
> mypage.epl:
> <html><pre>
> outerTEXT
> [*
> my $r = shift;
> print OUT "TEST:n";
> print OUT Data:umper:umper(
$::GLOBAL ); print OUT 
> Data:umper:umper
( $r ); *] <pre></html>
> 
> If I access mypage.epl through server A
> http://A/mypage.epl,
I got the following ( expected ) result:
> outerTEXT
> TEST:
> $VAR1 = {
>                     'key1' => A
>                 };
> 
> $VAR1 = bless( {}, 'Embperl::Req' );
> 
> If I call http://B/mypage.epl, I get :
> outerTEXT
> 
> Not even the static "TEST" ist printed,
neither the expected 
> "key1 => B"
> Attempts to set $udat{'somekey} fail because
"Can't call 
> method "init" 
> on unblessed reference at
> /usr/lib/perl5/site_perl/5.8.5/Apache/SessionX.pm"
and in 
> fact is $self in SessionX.pm undef.
> Attemps to access $r->app fail, because of 
"Can't call 
> method "app" on an undefined value".
> 
> If I force a recompile of the page and access it at
first 
> from server B everything is the other way round.
> 
> I expected each virtual host to have a global variable
called 
> $::GLOBAL and %udat and $r to behave "normal"
because, the 
> not only have their own Perlinterpreters but also
different 
> Embperl_Appnames and even the cookie name ist
different, so 
> that their should be IMHO no interference.
> 
> What am I missing here?
> Any hint is welcome.
> thanks in advance
> 
> 
> frank
> 
> --
> mit freundlichem Gruß,
> 
> Frank Wesemann
> Fotofinder GmbH         USt-IdNr. DE812854514
> Software Entwicklung    Web: http://www.fotofinder.net/

> Potsdamer Str. 96       Tel: +49 30 25 79 28 90
> 10785 Berlin            Fax: +49 30 25 79 28 999
> 
> Sitz: Berlin
> Amtsgericht Berlin Charlottenburg (HRB 73099)
> Geschäftsführer: Ali Paczensky
> 
> 
> 
> 
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
> For additional commands, e-mail: embperl-helpperl.apache.org
> 
> 
> ** Virus checked by BB-5000 Mailfilter ** 
> !DSPAM:416,4706a044121561827440373!
> 
> 

** Virus checked by BB-5000 Mailfilter **

------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribeperl.apache.org
For additional commands, e-mail: embperl-helpperl.apache.org


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )