diff options
author | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-08 02:59:06 +0000 |
---|---|---|
committer | rjung <rjung@13f79535-47bb-0310-9956-ffa450edef68> | 2011-11-08 02:59:06 +0000 |
commit | 757af73280a0a527c50f226cd73000cc65427a53 (patch) | |
tree | fc519ecfbbbce15dda6c154357d20a73ef322a2e /random/unix/apr_random.c | |
parent | 2bb0b33ba575e99d1f8d3b2b416fff42536dbb21 (diff) | |
download | libapr-757af73280a0a527c50f226cd73000cc65427a53.tar.gz |
Clean up references to rng struct when pool is
destroyed.
Backport of r1198921 from trunk and r1199083 from 1.5.x.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1199084 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'random/unix/apr_random.c')
-rw-r--r-- | random/unix/apr_random.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/random/unix/apr_random.c b/random/unix/apr_random.c index 852cfd6e3..b042b66bd 100644 --- a/random/unix/apr_random.c +++ b/random/unix/apr_random.c @@ -86,6 +86,23 @@ struct apr_random_t { static apr_random_t *all_random; +static apr_status_t random_cleanup(void *data) +{ + apr_random_t *remove_this = data, + *cur = all_random, + **prev_ptr = &all_random; + while (cur) { + if (cur == remove_this) { + *prev_ptr = cur->next; + break; + } + prev_ptr = &cur->next; + cur = cur->next; + } + return APR_SUCCESS; +} + + APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, apr_crypto_hash_t *pool_hash, apr_crypto_hash_t *key_hash, @@ -128,6 +145,7 @@ APR_DECLARE(void) apr_random_init(apr_random_t *g,apr_pool_t *p, g->next = all_random; all_random = g; + apr_pool_cleanup_register(p, g, random_cleanup, apr_pool_cleanup_null); } static void mix_pid(apr_random_t *g,unsigned char *H,pid_t pid) |