]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Some minor nit corrections in the thread code for rcu
authorNeil Horman <nhorman@openssl.org>
Mon, 17 Jun 2024 18:12:46 +0000 (14:12 -0400)
committerTomas Mraz <tomas@openssl.org>
Thu, 20 Jun 2024 14:56:39 +0000 (16:56 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24630)

(cherry picked from commit d38d2642287ef9a22f20e662a19c217c227043a6)

crypto/threads_none.c
crypto/threads_pthread.c
crypto/threads_win.c
test/threadstest.c

index e0387650fece80b59dc1b160208588893f7e3842..c2e6173bcac3fdf40c1d415029c1e468077c7509 100644 (file)
@@ -23,7 +23,8 @@ struct rcu_lock_st {
     struct rcu_cb_item *cb_items;
 };
 
-CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
+CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers,
+                                   ossl_unused OSSL_LIB_CTX *ctx)
 {
     struct rcu_lock_st *lock;
 
index 2a6e7aaf537ac00ce61be15107a7b6ac213210a4..0628db542f64219209b93c0e0f342f808e13abbc 100644 (file)
@@ -409,7 +409,9 @@ static void ossl_rcu_free_local_data(void *arg)
     OSSL_LIB_CTX *ctx = arg;
     CRYPTO_THREAD_LOCAL *lkey = ossl_lib_ctx_get_rcukey(ctx);
     struct rcu_thr_data *data = CRYPTO_THREAD_get_local(lkey);
+
     OPENSSL_free(data);
+    CRYPTO_THREAD_set_local(lkey, NULL);
 }
 
 void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock)
index a36e3752f655fb4b62917c8c65a53d4e2499c772..5ee0751b041df0a27795e3017aa4bbc7f02c9f0a 100644 (file)
@@ -190,6 +190,7 @@ static void ossl_rcu_free_local_data(void *arg)
     CRYPTO_THREAD_LOCAL *lkey = ossl_lib_ctx_get_rcukey(ctx);
     struct rcu_thr_data *data = CRYPTO_THREAD_get_local(lkey);
     OPENSSL_free(data);
+    CRYPTO_THREAD_set_local(lkey, NULL);
 }
 
 void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock)
index 2d05255132d3b6f8e6dac5dd15b3ea7500975c7d..b2b1ec2555ae523db3cec442e15403a827097147 100644 (file)
@@ -436,7 +436,7 @@ static int _torture_rcu(void)
     rcu_torture_result = 1;
 
     rcu_lock = ossl_rcu_lock_new(1, NULL);
-    if (!rcu_lock)
+    if (rcu_lock == NULL)
         goto out;
 
     TEST_info("Staring rcu torture");