I have Apache::Session::Oracle running. It creates the session fine, but
after accessing the page successfully a few times, the script gets held
up waiting for a lock to release and page never loads until I restart
Apache. Here is the sample code I am using. Is there something I need to
do with Apache::Session::Oracle, so it will release a lock it creates.
I am not that familiar with how locks are created in Oracle, but my DBA
took a look at the database, and said that there were some stale locks. I
can run Apache::Session::Oracle under CGI without a problem. Any tips?
brian
use strict;
use Apache;
use DBI ();
use CGI qw(:standard);
use vars qw($DBH);
use Apache::Session::Oracle;
use constant DB => 'DBI:Oracle:foo';
use constant DBAUTH => '<user_id>:<password>';
use constant EXPIRE => 3; # allow 3 days before expiration
use constant COOKIE_NAME => 'Session1';
my $r = Apache->request();
$r->status(200);
$r->content_type("text/html");
# Open the database
$DBH ||= DBI->connect(DB, split(':', DBAUTH, 2), {PrintError => 0})
|| die "Couldn't open database: ", $DBI::errstr;
my $session_id = cookie(COOKIE_NAME) unless param('new');
$session_id = $session_id ? $session_id : undef;
my %session;
tie %session, 'Apache::Session::Oracle',
$session_id,
{Handle => $DBH };
my $input = param('input');
$session{name} = $input if $input;
print header(-Cookie => [cookie(-name => COOKIE_NAME,
-value => $session{_session_id},
-expires => '+' . EXPIRE . 'd'),
cookie(-name => 'sessionID',
-value => 'no longer valid',
-expires => '-1d')
]
),
start_html(-Title => 'Hangman 7',
-bgcolor => 'white');
print<<__EOS__;
Hello<br>
Session ID number is: $session{_session_id}<br>
The Session ID is embedded in the URL<br>
<br>
Your input to the form was: $input<br>
Your name is <b>$session{name}</b><br>
<br>
<a href="http://penguin:8080/perl/example_db.perl">Reload this session</a><br>
<a href="http://penguin:8080/perl/example_db.perl?new=1">New session</a>
<form action="http://penguin:8080/perl/example_db.perl" method="post">
Type in your name here:
<input name="input">
<input type="submit" value="Go!">
</form>
__EOS__
print end_html;
--
Brian Lavender
http://www.brie.com/brian/