Hello!

I've tried to use Apache::Session (with DBI and SysVSemaphoreLocker), and it
failed.

Many people replied me here that "Apache::Session is OK". I've set
locking to NullLocker, and experienced data corruption.

Well, I've put an alarm inside my handler, and it bangs over and over
on the same place:

=== handler.pl ==
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 ($port, $addr) = Socket::sockaddr_in($r->connection->local_addr);
  return -1 if $port == 8000;
  local $SIG{ALRM} = sub {Carp::confess "Alarm ";};
  alarm 20;
  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",
 "*","*",
     { 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 => '*',
    Password => '*'};
 $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;
  alarm 2;
  untie %session;
  # warn "\[$$\] Session untied\n";
  alarm 0;

  return $res;
}
=== cut ===

It ALWAYS bangs like:
[Sun Jan 16 22:02:41 2000] [error] Alarm  at /usr/local/www/lib/handler.pl line 
114
        HTML::Mason::__ANON__('ALRM') called at /usr/libdata/perl/5.00503/mach/I
PC/Semaphore.pm line 92
        IPC::Semaphore::op('IPC::Semaphore=SCALAR(0x88eb6ac)', 15, 0, 4096, 31, 
0, 4096, 31, ...) called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session/
SysVSemaphoreLocker.pm line 69
        Apache::Session::SysVSemaphoreLocker::acquire_write_lock('Apache::Sessio
n::SysVSemaphoreLocker=HASH(0x87c9a84)', 'Apache::Session::DBI=HASH(0x8248a48)')
 called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 560
        Apache::Session::acquire_write_lock('Apache::Session::DBI=HASH(0x8248a48
)') called at /usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 478
        Apache::Session::save('Apache::Session::DBI=HASH(0x8248a48)') called at 
/usr/local/lib/perl5/site_perl/5.005/Apache/Session.pm line 375
        Apache::Session::TIEHASH('Apache::Session::DBI', undef, 'HASH(0x8ac3a64)
') called at /usr/local/www/lib/handler.pl line 136
        HTML::Mason::handler('Apache=SCALAR(0x88eb79c)') called at /dev/null lin
e 0
        eval {...} called at /dev/null line 0


I.e. due to some reason write lock NEVER EVER gets aquired by handler.

How do I debug the case?

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

Reply via email to