summaryrefslogtreecommitdiffstats
path: root/crypto/rand/md_rand.c
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
committerGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
commit5f834ab123af6444b7cffe21849e434ad6479f8a (patch)
tree0cc48f4fc085f781606cb118b715781651487cb3 /crypto/rand/md_rand.c
parent8528128b2a740d34d3ae1d43c525d7e6ea6d7f37 (diff)
Revert my earlier CRYPTO_THREADID commit, I will commit a reworked
version some time soon.
Diffstat (limited to 'crypto/rand/md_rand.c')
-rw-r--r--crypto/rand/md_rand.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/crypto/rand/md_rand.c b/crypto/rand/md_rand.c
index 59535b9e70..cfc78774f7 100644
--- a/crypto/rand/md_rand.c
+++ b/crypto/rand/md_rand.c
@@ -145,7 +145,8 @@ static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
* holds CRYPTO_LOCK_RAND
* (to prevent double locking) */
/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
-static CRYPTO_THREADID locking_tid;
+static unsigned long locking_thread_id = 0; /* valid iff crypto_lock_rand is set */
+static void *locking_thread_idptr = NULL; /* valid iff crypto_lock_rand is set */
#ifdef PREDICT
@@ -213,10 +214,8 @@ static void ssleay_rand_add(const void *buf, int num, double add)
/* check if we already have the lock */
if (crypto_lock_rand)
{
- CRYPTO_THREADID tid;
- CRYPTO_THREADID_set(&tid);
CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
- do_not_lock = !CRYPTO_THREADID_cmp(&locking_tid, &tid);
+ do_not_lock = (locking_thread_id == CRYPTO_thread_id()) && (locking_thread_idptr == CRYPTO_thread_idptr());
CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
}
else
@@ -374,7 +373,8 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
- CRYPTO_THREADID_set(&locking_tid);
+ locking_thread_id = CRYPTO_thread_id();
+ locking_thread_idptr = CRYPTO_thread_idptr();
CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
crypto_lock_rand = 1;
@@ -536,10 +536,8 @@ static int ssleay_rand_status(void)
* (could happen if a RAND_poll() implementation calls RAND_status()) */
if (crypto_lock_rand)
{
- CRYPTO_THREADID tid;
- CRYPTO_THREADID_set(&tid);
CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
- do_not_lock = !CRYPTO_THREADID_cmp(&locking_tid, &tid);
+ do_not_lock = (locking_thread_id == CRYPTO_thread_id()) && (locking_thread_idptr == CRYPTO_thread_idptr());
CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
}
else
@@ -551,7 +549,8 @@ static int ssleay_rand_status(void)
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
- CRYPTO_THREADID_set(&locking_tid);
+ locking_thread_id = CRYPTO_thread_id();
+ locking_thread_idptr = CRYPTO_thread_idptr();
CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
crypto_lock_rand = 1;
}