httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <>
Subject Re: Catching graceful restart in apache2 module
Date Fri, 31 Jul 2009 09:31:23 GMT
Petr Hracek wrote:

> Thank for the answer.
> Could you please explain in details how to do "register save-sessions as
> a pool cleanup".

You call a function that looks like this to register your cleanup:

    apr_pool_cleanup_register(pool, (void *) foo, foo_cleanup,

The function foo_cleanup() is a function you write yourself, that does
whatever you want the cleanup to do:

static apr_status_t foo_cleanup(void *dummy) {
    foo_t *foo = (foo_t *)dummy;

    ... do stuff using foo ...

    return APR_SUCCESS;

The variable foo is a void pointer that points to whatever you want your
cleanup to operate on, such as a pointer to your session config, or
whatever you want.

The cleanup gets run when the pool is deleted, ie when someone calls
apr_pool_destroy() on that pool.

What you need to do at this point is decide which pool you attach your
cleanup to.

The request pool is no good, because that's cleaned up at the end of the
request. The connection pool is also no good, because that gets cleaned
up after the connection dies. You're probably after the pool you're
given during the post_config hook, which gets destroyed on server
shutdown (graceful or otherwise).


View raw message