apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1198921 - /apr/apr/trunk/random/unix/apr_random.c
Date Mon, 07 Nov 2011 20:42:08 GMT
Author: sf
Date: Mon Nov  7 20:42:08 2011
New Revision: 1198921

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

Modified:
    apr/apr/trunk/random/unix/apr_random.c

Modified: apr/apr/trunk/random/unix/apr_random.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/random/unix/apr_random.c?rev=1198921&r1=1198920&r2=1198921&view=diff
==============================================================================
--- apr/apr/trunk/random/unix/apr_random.c (original)
+++ apr/apr/trunk/random/unix/apr_random.c Mon Nov  7 20:42:08 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)



Mime
View raw message