dev  

Re: svn commit: r677505 - /apr/apr-util/trunk/misc/apr_reslist.c

Bojan Smojver
Thu, 17 Jul 2008 02:51:28 -0700

Quoting [EMAIL PROTECTED]:

Use apr_pool_pre_cleanup_register for reslist cleanup

After thinking about this a bit more, this patch may introduce a somewhat unusual (possibly even dangerous) behaviour, as it changes the way cleanups normally work with APR pools.

Imagine a resource R, that in its constructor (or during its use) creates a number of sub-pools, of the pool to which R belongs, for its sub-resources S. It is a reasonable assumption that R will leave longer than any S, because sub-pools will be cleaned before the pool in which R lives. Hence, it would be reasonable to attach destruction of S to its sub-pool cleanups. This is how most of APR APIs work.

However, because we are destroying R before sub-pools in which S's live, when the time comes for any S to be destroyed, any reference to R is invalid and must not be used, which breaks the assumption that R lives longer than S. Hence, we are forcing people to create destructor of R in a manner destroys all S sub-resources explicitly, rather than letting writers rely on normal pool cleanup machinery.

Thoughts?

--
Bojan