summaryrefslogtreecommitdiffstats
path: root/crypto/init.c
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2018-03-07 19:25:55 +0100
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-03-19 15:04:40 +0100
commit7caf122e717e79afcb986fe217e77a630b67bf4c (patch)
tree5ced62615263082ab998c18c860b44c9b442ca39 /crypto/init.c
parent4e6647506331fc3b3ef5b23e5dbe188279ddd575 (diff)
Make the public and private DRBG thread local
This avoids lock contention. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5547)
Diffstat (limited to 'crypto/init.c')
-rw-r--r--crypto/init.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/init.c b/crypto/init.c
index 4a88e9cc02..cc3da4fb7d 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -352,6 +352,14 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
err_delete_thread_state();
}
+ if (locals->rand) {
+#ifdef OPENSSL_INIT_DEBUG
+ fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
+ "drbg_delete_thread_state()\n");
+#endif
+ drbg_delete_thread_state();
+ }
+
OPENSSL_free(locals);
}
@@ -389,6 +397,14 @@ int ossl_init_thread_start(uint64_t opts)
locals->err_state = 1;
}
+ if (opts & OPENSSL_INIT_THREAD_RAND) {
+#ifdef OPENSSL_INIT_DEBUG
+ fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
+ "marking thread for rand\n");
+#endif
+ locals->rand = 1;
+ }
+
return 1;
}