[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: module variables: all mine during a request?
From:       Perrin Harkins <perrin () elem ! com>
Date:       2004-07-29 0:44:14
Message-ID: 1091061854.3554.9.camel () localhost ! localdomain
[Download RAW message or body]

On Tue, 2004-07-27 at 21:20, Bryn Dyment wrote:
> I'm wondering if this approach to using variables in Perl modules (and
> setting/accessing these variables during a request) is sane (both for
> a $dbH and a "generic" variable):

Putting anything stateful in globals is a questionable practice, because
these globals will not be reset if your code dies half way through a
request.  It's better to use $r->pnotes() for storing this kind of
stuff, because it gets cleaned up automatically at the end of every
request, even if your code blows up.

However, there is no sharing of variables under mod_perl, so no one else
can affect your globals during a request.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic