On Mon, 31 Dec 2001, Ken Williams wrote:

> Hey,
>
> I'm having problems with Apache::Session, the symptom is that none of my
> data is getting written to the database.  It's not the nested-data
> problem, since I'm not using any nested data structures.
>
> After some investigation, I've discovered that the
> Apache::Session::Store::MySQL::DESTROY routine is getting called before
> the Apache::Session::MySQL::DESTROY routine, so when the latter is
> called it doesn't have any way to write to the database.
>
> I think Perl is supposed to guarantee that the outer object's DESTROY is
> called before the inner object's, but I think maybe this guarantee
> doesn't extend to the "global destruction" phase.  So I'm wondering why
> the session is getting cleaned up in global destruction rather than
> refcount destruction.  I've declared %session as a locally-scoped
> variable, so it should evaporate before global destruction, unless it's
> got circular data structures or something.  Anyone know what might be
> going on?
>
> This is Apache::Session version 1.53.
>
> Note: this problem isn't related to mod_perl, but IIRC this list is the
> proper place for discussing Apache::Session.

Ken,

Yeah this is the right list for Apache::Session discussion, and Perrin is
the unofficial guy who answers all the questios, since I don't pay that
much attention.

This seems like a really weird problem.  The Store module is destroyed
while another module still has a reference to it.  Unfortunately for you
and I, the only conclusion I have been able to draw is that Perl's DESTROY
magic is unreliable.  We have modules in my company where things are
randomly undefined in DESTROY subroutines, because the DESTROY of the
referenced thing has already been called.  So, somewhere in Perl there is
a bug, possibly an off-by-one in the reference counting.

Anyway you can work around it.  Explicitly call tied(%session)->save()
when the time is right.

-jwb

Reply via email to