Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev mix in another counter when the psuedo-device attach...



details:   https://anonhg.NetBSD.org/src/rev/40aa7a9475ef
branches:  trunk
changeset: 537910:40aa7a9475ef
user:      dan <dan%NetBSD.org@localhost>
date:      Tue Oct 08 09:59:27 2002 +0000

description:
mix in another counter when the psuedo-device attachment is called,
this actually happens *after* most of the sources have attached, so microtime
is as safe now as it was when they attached.

diffstat:

 sys/dev/rnd.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r a547760a43ff -r 40aa7a9475ef sys/dev/rnd.c
--- a/sys/dev/rnd.c     Tue Oct 08 09:56:17 2002 +0000
+++ b/sys/dev/rnd.c     Tue Oct 08 09:59:27 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $     */
+/*     $NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $     */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.32 2002/10/07 11:02:20 dan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.33 2002/10/08 09:59:27 dan Exp $");
 
 #include <sys/param.h>
 #include <sys/ioctl.h>
@@ -286,8 +286,19 @@
 void
 rndattach(int num)
 {
+       u_int32_t c;
 
+       /*
+        * rnd_init() is actually called very early on in the boot
+        * process, pseudo's don't get attached until much later
+        * (after many of the sources have been attached). 
+        * XXX Maybe this is left "in case", maybe it should be an assert?
+        */     
        rnd_init();
+
+       /* mix in another counter */
+       c = rnd_counter();
+       rndpool_add_data(&rnd_pool, &c, sizeof(u_int32_t), 0);
 }
 
 void
@@ -298,6 +309,10 @@
        if (rnd_ready)
                return;
 
+       /* 
+        * take a counter early, hoping that there's some variance in
+        * the following operations 
+        */
        c = rnd_counter();
 
        LIST_INIT(&rnd_sources);



Home | Main Index | Thread Index | Old Index