apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mladen Turk <mt...@apache.org>
Subject Re: Changing the order of cleanup for some core objects
Date Wed, 23 Jul 2008 06:56:08 GMT
Bojan Smojver wrote:
> On Wed, 2008-07-23 at 08:34 +0200, Mladen Turk wrote:
>> If you create a socket for example in the constructor,
>> socket registers it's own cleanup. This cleanup will be run
>> *before* destructor meaning you are convicted to apr_socket_close,
>> and you cannot cleanly close the socket via shutdown, or send
>> some data upon destruction.
> Hang the custom shutdown as cleanup against your socket's pool and this
> will then run before the socket is shut down.

Cannot do that. Cleanups are LIFO. First cleanup registered is res_clean
so it'll always be executed *last*. Socket cleanup is private, so
cannot modify that. The solution would be to make additional pool,
register additional cleanup that would do the pre_cleanup trick.
Other solution is that after constructor runs I call
cleanup_kill(res_clean); cleanup_register(res_clean) so it gets
re-registered as last so it will be run as first. But that might
sill cause problems in pool callback loop (detaching cleanups in
callback loop)


View raw message