You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Mikhail T." <mi...@aldan.algebra.com> on 2010/06/04 21:36:22 UTC

Qs on the post_config hook, restarts

Hello!

Various sources suggest, the hook can be called several times -- could 
someone summarize those times for the record?

For example, it appears, that upon start-up the hook is called once to 
"check the syntax" and then again -- for real. Mod-developers can check 
by recording previous invocations with apr_pool_userdata_set() 
(although, really, there should be some other mechanism).

Ok. Now, what about the "graceful restarts"? The hook is called again, 
understandably, but only once, right?

Now, when should a module free() its malloc()-ed memory and do other 
clean-up between restarts? It would seem, that the same process (the 
master httpd) is doing the dlopen() of the module upon every restart and 
thus its memory-use should be continuously growing...

My module, at least, is using some external libraries, so I can't rely 
on the apr_pools for clean-ups. How do I know, when to free-up the 
resources I've allocated?

Thanks!

    -mi


Re: Qs on the post_config hook, restarts

Posted by "Mikhail T." <mi...@aldan.algebra.com>.
04.06.2010 16:00, Nick Kew ???????(??):
> The answer is, yes you can and should use APR pools.
To translate this answer: no, there is no hook invoked, when a module 
should clean-up... Thanks.

What about the rest of my question -- about the sequence of post_config 
hook invocations?

    -mi


Re: Qs on the post_config hook, restarts

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 04 Jun 2010 15:36:22 -0400
"Mikhail T." <mi...@aldan.algebra.com> wrote:

> My module, at least, is using some external libraries, so I can't rely 
> on the apr_pools for clean-ups. How do I know, when to free-up the 
> resources I've allocated?

I'm guessing that's the crux of your question.

The answer is, yes you can and should use APR pools.  The basic principle is,
whenever you allocate something, you register a cleanup on the appropriate
pool at the same time, typically with something like:

  foo = libfoo_alloc( ... );
  apr_pool_cleanup_register(pool, foo, libfoo_free, apr_pool_cleanup_null);

(add wrappers where necessary, etc)

-- 
Nick Kew