]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Run the random pool setup and teardown functions with random_active
authorSimon Tatham <anakin@pobox.com>
Fri, 19 Jul 2013 17:44:42 +0000 (17:44 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 19 Jul 2013 17:44:42 +0000 (17:44 +0000)
nonzero rather than zero.

[originally from svn r9935]

sshrand.c

index 85dfa0b6bfbdfe40812d408154759d37044ae0c0..797fce7388e6bdb2d96f574433a4d62952d516bf 100644 (file)
--- a/sshrand.c
+++ b/sshrand.c
@@ -213,23 +213,24 @@ void random_ref(void)
     if (!random_active) {
        memset(&pool, 0, sizeof(pool));    /* just to start with */
 
+        random_active++;
+
        noise_get_heavy(random_add_heavynoise_bitbybit);
        random_stir();
 
        next_noise_collection =
            schedule_timer(NOISE_REGULAR_INTERVAL, random_timer, &pool);
     }
-
-    random_active++;
 }
 
 void random_unref(void)
 {
+    assert(random_active > 0);
+    if (random_active == 1) {
+        random_save_seed();
+        expire_timer_context(&pool);
+    }
     random_active--;
-    assert(random_active >= 0);
-    if (random_active) return;
-
-    expire_timer_context(&pool);
 }
 
 int random_byte(void)