Hi all,

We have a fairly simple handler responsible for maintaining
state on our web server.  Unfortunately, when we activate
it, server performance drops to about 1/10th of what it is
without.   After going through the handler and commenting
out parts and benchmarking (rinse, repeat), Apache::Session
appears to be the culprit.

I can't believe that the use of this module should have so
great an effect.  We have to be doing something
incorrectly.   Any advice would be greatly appreciated.

package Carescout::SessionHandler;
use strict;
use Apache;
use Apache::Session::DBI;

sub handler {
     my ( $r ) = shift;
     my ( $cookie ) = $r->header_in('Cookie') || undef;
     $cookie =~ s/SESSION_ID=(\w*)/$1/o;
     my ( %session );
     tie %session, 'Apache::Session::DBI', $cookie,
        {DataSource => 'dbi:mysql:cs',
         UserName => 'nobody',
         Password => 'xxxxxxxx'
         };
     if ( ! $session{ acl } ) {
         $session{ acl } = '0';
     }
     if ( ! $session{ uid } ) {
         $session{ uid } = '999999';
     }
     if ( ! $session{ services } ) {
         $session{ services } = '0';
     }
     $r->subprocess_env( 'SESSION_ID' => $session{
_session_id } );
     $r->subprocess_env( 'UID' => $session{ uid } );
     $r->subprocess_env( 'ACL' => $session{ acl } );
     $r->subprocess_env( 'SERVICES' => $session{ services }
);
     my ( $session_cookie ) = "SESSION_ID=$session{
_session_id };path=/;";
     tied( %session)->make_modified();
     untie %session;                    # not sure if we need this
     $r->header_out("Set-Cookie" => $session_cookie ) if !
$cookie;
}
1;
__END__


Thanks,
Chris

Reply via email to