You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Stas Bekman <st...@stason.org> on 2003/08/16 00:24:27 UTC
apr_hook_global_pool is not initialized by apr_initialize
apr_dynamic_fn_register needs an initialized apr_hook_global_pool, however
apr_initialize doesn't do that. Result: apr can't be used outside httpd,
unless apr_hook_global_pool is initialized manually. This contradicts:
/**
* Setup any APR internal data structures. This MUST be the first function
* called for any APR library.
* @remark See apr_app_initialize if this is an application, rather than
* a library consumer of apr.
*/
APR_DECLARE(apr_status_t) apr_initialize(void);
so it's not *any*. Is it an omission or by design? If by design apr_hash_make
should probably check whether the pool is valid.
Notice that initializing it, in apr_initialize doesn't prevent overriding
later in server/config.c:
apr_hook_global_pool=process->pconf;
that's the core that I get when calling an optional function:
#0 apr_palloc (pool=0x0, size=39) at apr_pools.c:621
#1 0x403a9820 in apr_hash_make (pool=0x0) at apr_hash.c:135
#2 0x403dc313 in apr_dynamic_fn_register (
szName=0x404b3fdb "apr_perlio_apr_file_to_PerlIO",
pfn=0x404b3c66 <apr_perlio_apr_file_to_PerlIO>) at apr_hooks.c:409
#3 0x404b3c30 in apr_perlio_init (my_perl=0x804b2c0) at apr_perlio.c:414
__________________________________________________________________
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
Re: apr_hook_global_pool is not initialized by apr_initialize
Posted by Stas Bekman <st...@stason.org>.
anybody cares to comment on this?
I have worked around this, doing:
#include "apr_hooks.h"
static void extra_apr_init(void)
{
if (apr_hook_global_pool == NULL) {
apr_pool_t *global_pool;
apr_status_t rv = apr_pool_create(&global_pool, NULL);
if (rv != APR_SUCCESS) {
fprintf(stderr, "Fatal error: unable to create global pool "
"for use with by the scoreboard");
}
/* XXX: mutex locking? */
apr_hook_global_pool = global_pool;
}
}
but shouldn't this be done by apr_initialize?
Stas Bekman wrote:
> apr_dynamic_fn_register needs an initialized apr_hook_global_pool,
> however apr_initialize doesn't do that. Result: apr can't be used
> outside httpd, unless apr_hook_global_pool is initialized manually. This
> contradicts:
>
> /**
> * Setup any APR internal data structures. This MUST be the first function
> * called for any APR library.
> * @remark See apr_app_initialize if this is an application, rather than
> * a library consumer of apr.
> */
> APR_DECLARE(apr_status_t) apr_initialize(void);
>
> so it's not *any*. Is it an omission or by design? If by design
> apr_hash_make should probably check whether the pool is valid.
>
> Notice that initializing it, in apr_initialize doesn't prevent
> overriding later in server/config.c:
>
> apr_hook_global_pool=process->pconf;
>
> that's the core that I get when calling an optional function:
>
> #0 apr_palloc (pool=0x0, size=39) at apr_pools.c:621
> #1 0x403a9820 in apr_hash_make (pool=0x0) at apr_hash.c:135
> #2 0x403dc313 in apr_dynamic_fn_register (
> szName=0x404b3fdb "apr_perlio_apr_file_to_PerlIO",
> pfn=0x404b3c66 <apr_perlio_apr_file_to_PerlIO>) at apr_hooks.c:409
> #3 0x404b3c30 in apr_perlio_init (my_perl=0x804b2c0) at apr_perlio.c:414
>
>
> __________________________________________________________________
> 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
--
__________________________________________________________________
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