On Tue, Jul 17, 2001 at 05:49:08PM -0700, Justin Erenkrantz wrote:
> Comments? Would this make anyone happy? =)
yes, funnily enough.
you intend this to be part of the sms 'utility' API, yes?
a bit like apr_pool_cleanup_register_file() and socket() etc, yes?
basically it would be a 'convenience' wrapper around the
cleanup-register, doing the typecasting etc. for you
around the void*s, yes?
[oh, yes, i see from the patch: yes it is :) :)]
> This would allow a non-related SMS to be reset when that particular
> SMS is reset.
non-related??
... mmm....
mmm... *wary*.
> I wonder what would happen if the thread SMS is destroyed and the
> cleanup is not unregistered. Hmm, that could be a problem.
also, what happens if the child sms is *already part of the parent*?
can you guarantee that the registration and destruction of the
sms, via cleanup, will not stuff the parent by effectively
destroying the child sms twice?
:)
> The idea is important though. I can work on the details if we
> agree this is the way to go. -- justin
in principle, i like it, it 'feels' right, but i can see that
there might be problems with people using it accidentally to
destroy sms childs twice, amongst other things...
> Index: include/apr_sms.h
> ===================================================================
> RCS file: /home/cvs/apr/include/apr_sms.h,v
> retrieving revision 1.38
> diff -u -r1.38 apr_sms.h
> --- include/apr_sms.h 2001/07/11 17:00:00 1.38
> +++ include/apr_sms.h 2001/07/18 00:41:27
> @@ -332,6 +332,14 @@
> apr_status_t
> (*cleanup_fn)(void *));
>
> /**
> + * Register a SMS to be cleaned up when we are reset or destroyed
> + * @param pms The parent SMS to register the cleanup function with
> + * @param cms The child SMS to destroy
> + */
> +APR_DECLARE(apr_status_t) apr_sms_cleanup_register_reset(apr_sms_t *pms,
> + apr_sms_t *cms);
> +
> +/**
> * Unregister a previously registered cleanup function
> * @param sms The memory system the cleanup function is registered
> * with
> Index: memory/unix/apr_sms.c
> ===================================================================
> RCS file: /home/cvs/apr/memory/unix/apr_sms.c,v
> retrieving revision 1.48
> diff -u -r1.48 apr_sms.c
> --- memory/unix/apr_sms.c 2001/07/11 14:20:02 1.48
> +++ memory/unix/apr_sms.c 2001/07/18 00:41:35
> @@ -722,6 +722,13 @@
> return APR_SUCCESS;
> }
>
> +APR_DECLARE(apr_status_t) apr_sms_cleanup_register_reset(apr_sms_t *pms,
> + apr_sms_t *cms)
> +{
> + return apr_sms_cleanup_register(pms, APR_ALL_CLEANUPS, cms,
> + apr_sms_reset);
> +}
> +
> APR_DECLARE(apr_status_t) apr_sms_cleanup_unregister(apr_sms_t *sms,
> apr_int32_t type,
> const void *data,