Weird behaviour with PerlFixupHandler under Apache 2 on different platforms

This is a discussion on Weird behaviour with PerlFixupHandler under Apache 2 on different platforms within the Linux Web Servers forums, part of the Web Server and Related Forums category; Hi. I had been running Server version: Apache/2.0.52, Server built: Nov 12 2004 02:43:30 under ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-06-2005
el.dodgero@gmail.com
 
Posts: n/a
Default Weird behaviour with PerlFixupHandler under Apache 2 on different platforms

Hi.

I had been running Server version: Apache/2.0.52, Server built: Nov
12 2004 02:43:30 under Solaris 9 with a custom PerlFixupHandler for
about a year. The PerlFixupHandler simply connects to the MySQL
database and, using the cookie information, reads out the session data
and populates it into %ENV.

Problem is, I just recently put together a new box, running a
disk-installed Knoppix, and with Server version: Apache/2.0.55, Server
built: Oct 27 2005 03:42:41.

The handler module is the same one, the databases have been migrated
over so this isn't a network latency for DBH connections sort of issue,
I already checked that.

The problem is that before, it worked beautifully. Now, it hangs,
chokes, and so on. Same code, totally worse behaviour. No error
messages, no log problems.

Actually, the pages *seem* to work fine, except that:
1) If there are too many dynamic sub-elements, such as my gallery pages
with 24 thumbnails per page, plus a few mod_perl includes, some of
those sub-elements don't ever work
2) It seems that if you hit the page again, or refresh it, have fun
waiting because your server response isn't coming.

This is even weirder in that I have wildcarded subdomains added in, and
if I make up a random subdomain and go to the sape page on the
subdomain, THAT works -- once.

However, nothing should have changed at all, except a tiny amount of
Apache version and a lot of OS and hardware -- of which the new box is
a significant upgrade -- a shiny Dell Athlon with 256MB RAM, compared
to the dusty old Sparc Ultra 5 with less memory than Ronald Reagan a
week before he kicked it.

If it weren't for the reasons for the change, I'd just go back at this
point to where it was all working. But I can't do that. I needed to
move because of those hardware issues, as well as a few Solaris issues.
Those being a combination of the fact that there seemed to be no way on
earth to get the Sparc to recognise a 40GB hdd, and I need file storage
space; and also because it was proving absolutely impossible to compile
ImageMagick on the Sun, and all those wonderful binary IM distributors
just didn't think to bother to include the Perlmagick APIs, which means
source was the only option.

So it has to stay on the Linux box, but it's not working on the linux
box.

Anyone have any ideas?


Here's the handler code:

package Local::Session2;

use DBI;

#my $sql = DBI->connect('DBI:mysql:apache','root','1+s@L1v3');

#use Apache2;
use Apache2::RequestRec();
use Apache2::RequestIO();
use Apache2::ServerRec();
use strict;

use CGI::Cookie;

use Apache2::Const(':common');

sub handler {
my $r = shift;
my $s = $r->server;
my $sql = $main::SQL; # this is created by the ChildInitHandler,
just a dbh
my %cookies = fetch CGI::Cookie;
my $sessionid;
$sessionid = $cookies{'session'}->value if defined
$cookies{'session'};
for my $envar (grep /^(SESSION|ACCESS)/, keys %ENV) {
delete $ENV{$envar} unless $envar eq 'SESSION_ID';
}

$ENV{SESSION_ID} = $sessionid;
unless ($sessionid) {
$ENV{SESSION_ID} = 0;
$ENV{NO_SESSION_REASON} = "No session cookie found";
for my $envar (grep /^(SESSION|ACCESS)/, keys %ENV) {
delete $ENV{$envar} unless $envar eq 'SESSION_ID';
}
#$sql->disconnect;
return DECLINED;
}

my $sessionTables = {
'xfx3d.net' => 'xfx_session',
'gothic-classifieds.com' => 'gc_session',
'art-geeks.com' => 'ag_session',
'mistressjadeor.com' => 'mj_session'
};

my $dom = $s->server_hostname();

# debug
for my $envar (grep !/^ORIGINAL_/, keys %ENV) {
$ENV{"ORIGINAL_$envar"} = $ENV{$envar};
}

$ENV{DB_DOMAIN_ORIG} = $dom;

unless ($dom =~ /^[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+$/) {
$ENV{DEBUG} = "Domain had to be stripped down";
if ($dom =~ s/.*\.([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+)/$1/) {
$ENV{DOMAIN_CATCH} = "Did some stripping??";
}
else {
$ENV{DOMAIN_CATCH} = "Didn't match???";
}
}
$ENV{DB_DOMAIN} = $dom;

my $session_table = $sessionTables->{$dom};
$ENV{SQL_SESSION_TABLE} = $sessionTables->{$dom};

unless ($session_table) {
$ENV{SESSION_ID} = 0;
$ENV{NO_SESSION_REASON} = "No session table found for server
$dom";
for my $envar (grep /^(SESSION|ACCESS)/, keys %ENV) {
delete $ENV{$envar} unless $envar eq 'SESSION_ID';
}
#$sql->disconnect;
return DECLINED;
}

my $get_session_st = <<"EOF";
SELECT *
FROM $session_table
WHERE id = ?
EOF

my $get_session = $sql->prepare($get_session_st);

$ENV{GET_SESSION_PREPARED} = ref $get_session;

if ($sql->errstr) {
$ENV{SESSION_ID} = '0E0';
$ENV{SQL_PREPARE_GET_SESSION_ERR} = $sql->errstr;
#$sql->disconnect;
return DECLINED;
}

my $rows = $get_session->execute($sessionid);
unless ($rows+0) {
open ERRLOG, ">>/usr/local/apache2/logs/session_errlog";
print ERRLOG "Session error (no rows returned): ",
$get_session->errstr, "\n";
print STDERR "Session error (no rows returned): ",
$get_session->errstr, "\n";
close ERRLOG;
$ENV{SQL_EXECUTE_GET_SESSION_ERR} = $get_session->errstr;
#$sql->disconnect;
return DECLINED;
}

if ($get_session->errstr) {
$ENV{SESSION_ID} = '0E0';
$ENV{SQL_EXECUTE_GET_SESSION_ERR} = $get_session->errstr;
open ERRLOG, ">>/usr/local/apache2/logs/session_errlog";
print ERRLOG "Session error (no rows returned): ",
$get_session->errstr, "\n";
print STDERR "Session error (no rows returned): ",
$get_session->errstr, "\n";
close ERRLOG;
#$sql->disconnect;
return DECLINED;
}

my $session = $get_session->fetchrow_hashref;
$get_session->finish;

if ($session) {
my $expiry = $session->{remember} eq 'Yes' ? '+1y' : '+1d';
my $pcookie = CGI::Cookie->new($r,
-name => 'session',
-value => $sessionid,
-expires => $expiry,
-path => '/',
-domain => ".$dom");
$r->headers_out->set('Set-Cookie' => $pcookie);

for my $svar (grep {$_ ne 'access'} keys %{$session}) {
$ENV{uc("SESSION_$svar")} = $session->{$svar};
}

if ($session->{access}) {
my @access = split /;/, $session->{access};

for my $a (@access) {
my ($ap, $t) = split /:/, $a;
$ENV{uc("ACCESS_$ap")} = $t;
}
}

my $update_session_st = <<"EOF";
UPDATE $session_table
SET last_action = NOW()
WHERE id = ?
EOF
my $update_session = $sql->prepare($update_session_st);
$update_session->execute($sessionid);
$update_session->finish;
}

else {
$ENV{SESSION_ID} = 0;
$ENV{NO_SESSION_REASON} = "Session id not found in
$session_table";
for my $envar (grep /^(SESSION|ACCESS)/, keys %ENV) {
delete $ENV{$envar} unless $envar eq 'SESSION_ID';
}
my $mcookie = CGI::Cookie->new($r,
-name => 'session',
-value => '',
-expires => '-1d',
-path => '/',
-domain => ".$dom");
$r->headers_out->set('Set-Cookie' => $mcookie);
}
#$sql->disconnect;
return DECLINED;
}

1;

  #2 (permalink)  
Old 12-06-2005
el.dodgero@gmail.com
 
Posts: n/a
Default Re: Weird behaviour with PerlFixupHandler under Apache 2 on different platforms

BTW I should note -- I know Apache 2.2 is out, but I'm using PHP on the
site, too, and haven't seen any indication there's a mod_php for 2.2

  #3 (permalink)  
Old 12-06-2005
gerryt@vcn.bc.ca
 
Posts: n/a
Default Re: Weird behaviour with PerlFixupHandler under Apache 2 on different platforms


el.dodgero@gmail.com wrote:

some snippage

> However, nothing should have changed at all, except a tiny amount of
> Apache version and a lot of OS and hardware -- of which the new box is
> a significant upgrade -- a shiny Dell Athlon with 256MB RAM, compared
> to the dusty old Sparc Ultra 5 with less memory than Ronald Reagan a
> week before he kicked it.

Good one : >

> If it weren't for the reasons for the change, I'd just go back at this
> point to where it was all working. But I can't do that. I needed to
> move because of those hardware issues, as well as a few Solaris issues.
> Those being a combination of the fact that there seemed to be no way on
> earth to get the Sparc to recognise a 40GB hdd, and I need file storage
> space; and also because it was proving absolutely impossible to compile
> ImageMagick on the Sun, and all those wonderful binary IM distributors
> just didn't think to bother to include the Perlmagick APIs, which means
> source was the only option.


OK using an under Ultra 5 for something like this is a bit of a
testimonial
to how good SPARC stuff is... Even when the box has been EOLd since
forever and is probably unpatched on all kinds of levels and had less
than 256 MB of RAM??

I pulled down the ImageMagick sources
and had the stuff installed in no time so I dont know what problems
you had compiling the source! The ImageMagick source is some
of the most portable stuff Ive encountered anywhere.
There was one issue with the configured
Makefile where -pthread is confused with -pthreads. One is a gcc
option the other is a Sun library. Pretty easy fix.

You have been living under a rock (just kidding) so
Ill let you know about something: Solaris 10
Its available on "x86" and SPARC.
It has gcc and Apache 2.0 installed already. Plugging in php with
apxs is "cake".

Something else: Sun Studio 11 is downloadable on the Sun web site.
It is preferrable to using gcc given you are using perl .
And it compiles just fine using -xO5 on my Blade 2000 (fairly highly
optimized).

> So it has to stay on the Linux box, but it's not working on the linux box.


Not really. But thats "conventional wisdom" these days.

> Anyone have any ideas?


Well whatever is broken currently may be an easy fix on the LieNux box,
I cant assist you with any bugs in the code (if any),
but given how inexpensive older Sun servers are on eBay....
Or you could give Solaris 10 x86/x64 a whirl on another disk/partition
on the same box?? i.e. Can you reproduce the problem on Solaris 10?

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0