On Thu, 10 Jul 2003, Joshua Moore-Oliva wrote:
> This code here Fixed the problem by running the cleanups first then destroying
> the subpools.
>
> run_cleanups(&pool->cleanups);
>
> while (pool->child)
> apr_pool_destroy(pool->child);
-1 .. the order is correct as-is by design, I promise. :)
> Sample pseudo//simplified code that causes the problem is below for further
> clarification.
>
> apr_status_t file_field_clean( t ) {
> apr_pool_destroy( t->read_pool );
> apr_pool_destroy( t->write_pool );
> free(t);
>
> return APR_SUCCESS;
> }
All you have to do is get rid of those two apr_pool_destroy() lines and it
will work fine. You can go ahead and free(t) in your cleanup function.
Then when you cleanup "pool", read_pool and write_pool will be cleaned up
and then t will be freed.
The point is that you should never register a cleanup in a parent pool
that calls apr_pool_destroy() on a child pool. It's already done
implicitly.
--Cliff