Hello!

I've just tried to work (again) with Apache::Session::DBI, and the
following handler:
# skipped
sub handler {
  my ($r) = @_;
  return -1 if $r->method !~ /^(GET|POST|HEAD)$/;
  return -1 
    if defined($r->content_type) && $r->content_type !~ m|^text/|io;
  my %session;
  my $cookie = $r->header_in('Cookie');
  $cookie =~ s/SESSION_ID=(\w*)/$1/;
  # Unless exists session_id, clean it!
  my $dbh = DBI->connect
    ("DBI:mysql:mail2pager",
     "mine", "password",
     { RaiseError => 1, PrintError => 1, 
       AutoCommit => 1, }
    );
  my $sth = $dbh->prepare_cached(q{
    select id from sessions
      where id = ?
    });
  $sth->execute($cookie);
  my $rses;
  $rses = $sth->fetchall_arrayref();
  if (scalar @$rses == 0) {
    $cookie = undef;
  }
  tie %session, 'Apache::Session::DBI', $cookie, 
  { DataSource => 'dbi:mysql:mail2pager', UserName => 'tarkhil', 
    Password => 'cypurcad'};
  warn "\[$$\] Tied session $session{_session_id}\n";
$r->header_out("Set-Cookie" => "SESSION_ID=$session{_session_id};") 
    if ( !$cookie );
  
  # This creates a global called %session that is accessible in all components
  
  # Feel free to rename this as needed.
  #
  local *HTML::Mason::Commands::session = \%session;
  
  my $res = $ah->handle_request($r);
  warn "\[$$\] Going to untie session $session{_session_id}\n";  
  untie %HTML::Mason::Commands::session;
  untie %session;
  warn "\[$$\] Session untied\n";
  return $res;
}


produced the following trace:

[92525] Tied session c1e710ab3c0e64a2
[92525] Going to untie session c1e710ab3c0e64a2
^^^^^^^
[92526] Tied session 8e38e48671c2d782
[92523] Going to untie session 4fc7720c37573e95
[92523] Session untied
[92526] Going to untie session 8e38e48671c2d782
[92526] Session untied
[92534] Tied session 0e9ffc7f9428baae
[92534] Going to untie session 0e9ffc7f9428baae
[92534] Session untied

The session being untied by PID 92525 NEVER got untied. 

Does anyone have any ideas on that behaviour?

-- 
Alexander B. Povolotsky                            [ICQ 18277558]
[2:5020/145]                                    [[EMAIL PROTECTED]]

Reply via email to