Mladen Turk
Tue, 22 Jul 2008 02:12:12 -0700
Joe Orton wrote:
Here's how I would do it:0. create a subpool for the reslist as a whole, P 1. create a subpool Qn of P for each resource Rn in the reslist code, and pass that Qn to the constructor and destructor; store a reference to Qn in the apr_res_t for Rn2. register the resource destructor as a cleanup on Qn, for the corresponding resource Rn 3. destroy_resource(Rn) just destroys the Qn subpool4. reslist_cleanup() no longer calls destroy_resource() on each resource; it can rely on subpool destruction to do that 5. reslist_cleanup() is registered against P rather than the passed-in pool6. apr_reslist_destroy() just destroys P I can't see any cleanup ordering problems with that scheme.
If the user creates a subpool the problem will still be present because this sub pool will be destroyed before the destructor is called. Also any resource allocated from this pool will be destroyed in advance to the destructor (since its registered first, it'll be called last), while for apr_reslist_invalidate it won't. Don't think that'll work. Regards -- ^(TM)