You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Perrin Harkins <pe...@elem.com> on 2004/01/08 22:14:44 UTC
Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object
is used in a subroutine
On Thu, 2004-01-08 at 15:43, Alexander Bergolth wrote:
> Why do I create a closure? If i'd create a closure I would have to store
> a reference to an _anonymous sub
No, that's a common misconception. Closures and anonymous subs are two
totally separate things, although they can be used together. See the
explanation here:
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Understanding_Closures____the_Easy_Way
There is more discussion in the list archives.
> My version uses a regular (named-) sub and the scope of the variable $r
> should be lexically local to the enclosing block.
And it is, but your sub creates a closure so that when $r changes in the
enclosing block that is not seen in your sub. The simplest solution is
to pass $r every time.
> Moreover I've read that Apache->request should be avoided in mod_perl2:
> http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache_E_gt_request_
That only applies to threaded MPMs, and modules you release that others
might want to run under threaded MPMs.
- Perrin
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object
is used in a subroutine
Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
> On Thu, 2004-01-08 at 16:34, Stas Bekman wrote:
>
>>But since we expect most modules to run under any MPM, it usually applies to
>>any code.
>
>
> Any code that you plan to release on CPAN, that is. It's still okay in
> internal code when you know you won't be running threaded MPMs.
You are correct, Perrin.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object
is used in a subroutine
Posted by Perrin Harkins <pe...@elem.com>.
On Thu, 2004-01-08 at 16:34, Stas Bekman wrote:
> But since we expect most modules to run under any MPM, it usually applies to
> any code.
Any code that you plan to release on CPAN, that is. It's still okay in
internal code when you know you won't be running threaded MPMs.
- Perrin
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object
is used in a subroutine
Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
[...]
>>Moreover I've read that Apache->request should be avoided in mod_perl2:
>>http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache_E_gt_request_
>
>
> That only applies to threaded MPMs, and modules you release that others
> might want to run under threaded MPMs.
But since we expect most modules to run under any MPM, it usually applies to
any code.
I doubt one ever needs to use Apache->request. CGI.pm now accepts $r as an
argument to CGI->new() and if you need to access $r from elsewhere in your
code a Singleton should be used.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object
is used in a subroutine
Posted by Alexander Bergolth <le...@strike.wu-wien.ac.at>.
On 01/08/2004 10:14 PM, Perrin Harkins wrote:
> On Thu, 2004-01-08 at 15:43, Alexander Bergolth wrote:
>
>>Why do I create a closure? If i'd create a closure I would have to store
>>a reference to an _anonymous sub
>
> No, that's a common misconception. Closures and anonymous subs are two
> totally separate things, although they can be used together. See the
> explanation here:
> http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Understanding_Closures____the_Easy_Way
Thanks for the explanation!
--leo
--
-----------------------------------------------------------------------
Alexander (Leo) Bergolth leo@leo.wu-wien.ac.at
WU-Wien - Zentrum fuer Informatikdienste http://leo.wu-wien.ac.at
Computers are like air conditioners -
they stop working properly when you open Windows
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html