You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2002/01/29 10:54:57 UTC

[patch] default request pool sub

I'm not sure if I've picked the best name, but I need this wrapper for 
compat. If I have it I don't need to prototype functions required to 
provide the pool argument as p=SOME_DEFAULT, but just p,

So now in compat.pm we can write wrappers:

my $req_pool = APR::Pool::from_current_request();
APR::Foo::bar($req_pool, ...)

Index: xs/APR/Pool/APR__Pool.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/Pool/APR__Pool.h,v
retrieving revision 1.4
diff -u -r1.4 APR__Pool.h
--- xs/APR/Pool/APR__Pool.h	8 May 2001 04:20:17 -0000	1.4
+++ xs/APR/Pool/APR__Pool.h	29 Jan 2002 09:30:28 -0000
@@ -72,3 +72,7 @@
                                mpxs_cleanup_run,
                                apr_pool_cleanup_null);
  }
+
+/* if inside request, this returns current r->pool */
+#define mpxs_APR__Pool_from_current_request() modperl_sv2pool(aTHX_ 
&PL_sv_undef)
+
Index: xs/maps/modperl_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/modperl_functions.map,v
retrieving revision 1.34
diff -u -r1.34 modperl_functions.map
--- xs/maps/modperl_functions.map	29 Jan 2002 07:47:25 -0000	1.34
+++ xs/maps/modperl_functions.map	29 Jan 2002 09:30:28 -0000
@@ -102,3 +102,5 @@
  MODULE=APR::String
   mpxs_APR__String_format_size

+MODULE=APR::Pool
+apr_pool_t *:DEFINE_from_current_request

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] default request pool sub

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Wed, 30 Jan 2002, Stas Bekman wrote:
>  
> 
>>Sure, be it ModPerl::Util:: function. How should it be called? Can I use 
>>the same code I've used for APR::Pool::from_current_request() in my orig 
>>post.
>>
> 
> ModPerl::Util::default_pool();


so as you say below, we don't need this function for now.


>>Take the case of the Apache::Util::ht_time wrapper. We cannot use 
>>Apache->request->pool without fallback, since we don't know where it's 
>>used. So I prefer to have one function that returns some pool for sure 
>>to be used in all wrappers needing this functionality. Rather than 
>>trying Apache->request->pool and falling back to pconf in every compat 
>>wrapper we need a poll.
>>
> 
> in this case, if ht_time is used at request time without
> PerlOptions +GlobalRequest, then all calls to ht_time leak into pconf.
> it is also unsafe to use pconf at request time with threaded MPMs.


That's clear.


> i doubt anybody is using ht_time() at startup.  i think it would be best
> to start out using Apache->request->pool here.  maybe adding this in
> Apache::compat.pm instead of ModPerl::Util::default_pool():
> 
> sub default_pool {
>     my $r = Apache->request;
>     die "need to configure 'PerlOptions +GlobalRequest'" unless $r;
>     return $r->pool;
> }
> 
> after all, this function should only be used for compat wrappers.

Fine with me. So you say that we "assume" that nobody uses functions 
that in 2.0 require a pool arg, outside of request phases. And if 
somebody does use any of these functions during the startup, we will 
deal with that when the time comes.

BTW, we need to add another die() above, in case that the function is 
used at the startup. How do you say this in Perl?

sub default_pool {
      die "Can be used only during request" unless ???
      my $r = Apache->request;
      die "need to configure 'PerlOptions +GlobalRequest'" unless $r;
      return $r->pool;
  }





_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] default request pool sub

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 30 Jan 2002, Stas Bekman wrote:
 
> Sure, be it ModPerl::Util:: function. How should it be called? Can I use 
> the same code I've used for APR::Pool::from_current_request() in my orig 
> post.

ModPerl::Util::default_pool();
 
> Take the case of the Apache::Util::ht_time wrapper. We cannot use 
> Apache->request->pool without fallback, since we don't know where it's 
> used. So I prefer to have one function that returns some pool for sure 
> to be used in all wrappers needing this functionality. Rather than 
> trying Apache->request->pool and falling back to pconf in every compat 
> wrapper we need a poll.

in this case, if ht_time is used at request time without
PerlOptions +GlobalRequest, then all calls to ht_time leak into pconf.
it is also unsafe to use pconf at request time with threaded MPMs.

i doubt anybody is using ht_time() at startup.  i think it would be best
to start out using Apache->request->pool here.  maybe adding this in
Apache::compat.pm instead of ModPerl::Util::default_pool():

sub default_pool {
    my $r = Apache->request;
    die "need to configure 'PerlOptions +GlobalRequest'" unless $r;
    return $r->pool;
}

after all, this function should only be used for compat wrappers.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] default request pool sub

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Tue, 29 Jan 2002, Stas Bekman wrote:
> 
> 
>>I'm not sure if I've picked the best name, but I need this wrapper for 
>>compat. If I have it I don't need to prototype functions required to 
>>provide the pool argument as p=SOME_DEFAULT, but just p,
>>
>>So now in compat.pm we can write wrappers:
>>
>>my $req_pool = APR::Pool::from_current_request();
>>APR::Foo::bar($req_pool, ...)
>>
> 
> APR:: functions should not default any APR::Pool argument, only
> Apache:: compat wrappers.


Yes, sorry, talking about compat wrappers only.

> in which case the wrappers should just use
> Apache->request->pool;  or if the function is really needed (like to
> fallback on pconf if there is no Apache->request), it should be a
> ModPerl::Util:: function.  nothing in APR::*.xs should reference modperl_
> symbols, so they can be used outside of mod_perl.

Sure, be it ModPerl::Util:: function. How should it be called? Can I use 
the same code I've used for APR::Pool::from_current_request() in my orig 
post.

Take the case of the Apache::Util::ht_time wrapper. We cannot use 
Apache->request->pool without fallback, since we don't know where it's 
used. So I prefer to have one function that returns some pool for sure 
to be used in all wrappers needing this functionality. Rather than 
trying Apache->request->pool and falling back to pconf in every compat 
wrapper we need a poll.

So if the function ModPerl::Util::from_current_request() is cool with 
you, what should be the best name?

We will also document that this function is deprecated and used only in 
the compat wrappers.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] default request pool sub

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 29 Jan 2002, Stas Bekman wrote:

> I'm not sure if I've picked the best name, but I need this wrapper for 
> compat. If I have it I don't need to prototype functions required to 
> provide the pool argument as p=SOME_DEFAULT, but just p,
> 
> So now in compat.pm we can write wrappers:
> 
> my $req_pool = APR::Pool::from_current_request();
> APR::Foo::bar($req_pool, ...)

APR:: functions should not default any APR::Pool argument, only
Apache:: compat wrappers.  in which case the wrappers should just use
Apache->request->pool;  or if the function is really needed (like to
fallback on pconf if there is no Apache->request), it should be a
ModPerl::Util:: function.  nothing in APR::*.xs should reference modperl_
symbols, so they can be used outside of mod_perl.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org