You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by rj...@apache.org on 2011/11/08 03:58:26 UTC

svn commit: r1199083 - /apr/apr/branches/1.5.x/random/unix/apr_random.c

Author: rjung
Date: Tue Nov  8 02:58:26 2011
New Revision: 1199083

URL: http://svn.apache.org/viewvc?rev=1199083&view=rev
Log:
Clean up references to rng struct when pool is
destroyed.

Backport of r1198921 from trunk.

Modified:
    apr/apr/branches/1.5.x/random/unix/apr_random.c

Modified: apr/apr/branches/1.5.x/random/unix/apr_random.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/random/unix/apr_random.c?rev=1199083&r1=1199082&r2=1199083&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/random/unix/apr_random.c (original)
+++ apr/apr/branches/1.5.x/random/unix/apr_random.c Tue Nov  8 02:58:26 2011
@@ -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_ra
 
     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)