* prng.c (init_once): Variable deleted.
authorKen Raeburn <raeburn@mit.edu>
Wed, 2 Jun 2004 23:41:51 +0000 (23:41 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 2 Jun 2004 23:41:51 +0000 (23:41 +0000)
(krb5_c_random_add_entropy): Do the initialization once, using the yarrow_lock
mutex instead of k5_once to protect it.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16392 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/crypto/ChangeLog
src/lib/crypto/prng.c

index 952aaa9a5456c13ceb82498bdbb95617b20b35c3..b30a22c9228dfccc1c4b34ec3f868ab343e54fcb 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-02  Ken Raeburn  <raeburn@mit.edu>
+
+       * prng.c (init_once): Variable deleted.
+       (krb5_c_random_add_entropy): Do the initialization once, using
+       the yarrow_lock mutex instead of k5_once to protect it.
+
 2004-05-24  Ezra Peisach  <epeisach@mit.edu>
 
        * t_nfold.c (fold_kerberos): Change nbytes argument to unsigned.
index be757d21ce05fef7dc49cd1a85db2ce3d62d9124..f9ea8696dcb1c0d9ad71792c78c52f68c1b92b0f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001, 2002 by the Massachusetts Institute of Technology.
+ * Copyright (C) 2001, 2002, 2004 by the Massachusetts Institute of Technology.
  * All rights reserved.
  *
  * 
@@ -30,7 +30,6 @@
 
 #include "yarrow.h"
 static Yarrow_CTX y_ctx;
-static k5_once_t init_once = K5_ONCE_INIT;
 static int inited, init_error;
 static k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER;
 
@@ -95,17 +94,16 @@ krb5_c_random_add_entropy (krb5_context context, unsigned int randsource,
   yerr = krb5int_crypto_init();
   if (yerr)
       return yerr;
-  /* Run the Yarrow init code, if not done already.  */
-  yerr = k5_once(&init_once, do_yarrow_init);
-  if (yerr)
-      return yerr;
-  /* Return an error if the Yarrow initialization failed.  */
-  if (init_error)
-      return KRB5_CRYPTO_INTERNAL;
   /* Now, finally, feed in the data.  */
   yerr = k5_mutex_lock(&yarrow_lock);
   if (yerr)
       return yerr;
+  if (!inited)
+      do_yarrow_init();
+  if (init_error) {
+      k5_mutex_unlock(&yarrow_lock);
+      return KRB5_CRYPTO_INTERNAL;
+  }
   yerr = krb5int_yarrow_input (&y_ctx, randsource,
                               data->data, data->length,
                               entropy_estimate (randsource, data->length));