EvanCarroll has asked for the wisdom of the Perl Monks concerning the following question:

Mod_perl problem as follows, check out my Mason autohandler, synopsis, at end:
<%shared> ## Verfiy we have a cookie with a _session_id my $c = Apache2::Cookie->fetch($r); if ( exists $c->{'WBT_Session'} ) { $c= ($c->{'WBT_Session'}->value)[0]; } else { $m->clear_buffer; $m->subexec('/index.html', error => 201 ); $m->abort; } ## Verify we have session that matches cookies ID my %APACHE_SESSION; eval { tie %APACHE_SESSION, 'Apache::Session::Postgres', $c, { Handle => $dbh, Commit => 1, };}; if ( $@ ) { if ( $@ ) { ## No tuple with matching ID (form cookie), bogus data. $m->clear_buffer; $dbh->rollback; $m->subexec('/index.html', error => 301 ); $m->abort; } } ## Verify that the sessioned user still has an entry in the users ta +ble ## Save user information into $U by ref my $U = $dbh->selectrow_hashref( qq{ SELECT * FROM "users" WHERE pkid = ? }, {}, $APACHE_SESSION{'p +kid'} ); if ( defined $U ) { ##@@## HERE IS PROBLEM ##@@## WORKS FINE IF I DON'T SEND S ( %APACHE_SESSION REF ) ##@@## STALLS IF I SEND S! $m->call_next( S => \%APACHE_SESSION, U => $U); } else { $m->clear_buffer; $m->subexec('/index.html', error => 101 ); $m->abort; } </%shared> <%cleanup> $dbh->commit(); untie %APACHE_SESSION; </%cleanup>

What happens is this:
  1. autohandler, finds a WBT_Session cookie or errors
  2. cookie session value refrences _a_session value in session table
  3. it reads users id from session table.
  4. refrences that userid with user data from user tbl.
  5. calls the next mason component in the stack with a refrence to Apache::Session::Postgres object, and a refrence to the user data from user table.

The problem is in the sesion object, at first I figured this would be one thread/fork per process, so refrences would be valid, and but aparently they aren't. If I comment out the the sending of the sesion refnrece everything works fine and dandy, however If i uncomment out session refrence apache just hangs indefinitly.


www.wbt-modules.com, for example of hang up.

anyone have any ideas on how to fix this problem, or even what it is



Evan Carroll
www.EvanCarroll.com


update

This prolbem is so damn weird, everything works fine if I change this:

if ( defined $U ) { $m->call_next( S => \%APACHE_SESSION, U => $U); }
if ( defined $U ) { my %APACHE_SESSION = %APACHE_SESSION; $m->call_next( S => \%APACHE_SESSION, U => $U); }

Replies are listed 'Best First'.
Re: Major Mod_perl/Apache2 dilema
by johnnywang (Priest) on Oct 17, 2005 at 05:49 UTC
    (Please excuse me for this comment, I've seen a few questions today where it's really difficult to figure out the question) Can you please put the problem also as comments in your code? at exactly the line that's causing the problem. When you describe the problem in text, and not using the exact variable name as in the code, the reader gets confused. Thanks.
      No problem, specific text point out.
      ##@@## HERE IS PROBLEM ##@@## WORKS FINE IF I DON'T SEND S ( %APACHE_SESSION REF ) ##@@## STALLS IF I SEND S! $m->call_next( S => \%APACHE_SESSION, U => $U);


      Evan Carroll
      www.EvanCarroll.com
Re: Major Mod_perl/Apache2 dilema
by perrin (Chancellor) on Oct 17, 2005 at 20:04 UTC
    Others have reported this on the Mason list. Passing the blessed session object like this seems to make it not go out of scope, which breaks the lock behavior of Apache::Session. The reason is not clear yet.
Re: Major Mod_perl/Apache2 dilema
by Anonymous Monk on Oct 17, 2005 at 08:22 UTC

    I suggest regarding specific perl technology should posted to the relevant mailinglist. They have more knowledge and experience regarding their specific technology and its quirks. And mod_perl and mason communities are very active.

    FYI, there is some long discussion regarding mod_perl2/apache2 in the mod_perl mailinglist recently. You might want to go through the archive for that.

      Perlmonks has always been an accepted medium for these types of questions =/ I'm not sure it is the technology, It could be my misunderstanding of it. I'm trying to send a refrence to a tied hash to a child component in Mason? Should I be experiencing problems?


      Evan Carroll
      www.EvanCarroll.com