I'm not sure what you are trying to do, but I think the functions apr_reslist_create and apr_pool_cleanup_register can help you. One of the parameters in the apr_reslist_create function is apr_reslist_destructor, which you can use to pass the destructor function. Also, I think you should take a look at the source code of the mod_dbd module, as this is a pretty good example of how to create and clean up external resources from the apache process.
Apr-Util apr_reslist_create
Apr apr_pool_cleanup_register
source share