mirror of
https://github.com/openssl/openssl.git
synced 2024-12-15 06:01:37 +08:00
24d16d3a19
Currently, rcu has a global bit of data, the CRYPTO_THREAD_LOCAL object to store per thread data. This works in some cases, but fails in FIPS, becuase it contains its own copy of the global key. So 1) Make the rcu_thr_key a per-context variable, and force ossl_rcu_lock_new to be context aware 2) Store a pointer to the context in the lock object 3) Use the context to get the global thread key on read/write lock 4) Use ossl_thread_start_init to properly register a cleanup on thread exit 5) Fix up missed calls to OSSL_thread_stop() in our tests Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24162)
34 lines
1.1 KiB
C
34 lines
1.1 KiB
C
/*
|
|
* Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.
|
|
*
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#ifndef OPENSSL_RCU_H
|
|
# define OPENSSL_RCU_H
|
|
# pragma once
|
|
|
|
#include "crypto/context.h"
|
|
|
|
typedef void (*rcu_cb_fn)(void *data);
|
|
|
|
typedef struct rcu_lock_st CRYPTO_RCU_LOCK;
|
|
|
|
CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx);
|
|
void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock);
|
|
void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock);
|
|
void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock);
|
|
void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock);
|
|
void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock);
|
|
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock);
|
|
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data);
|
|
void *ossl_rcu_uptr_deref(void **p);
|
|
void ossl_rcu_assign_uptr(void **p, void **v);
|
|
#define ossl_rcu_deref(p) ossl_rcu_uptr_deref((void **)p)
|
|
#define ossl_rcu_assign_ptr(p,v) ossl_rcu_assign_uptr((void **)p, (void **)v)
|
|
|
|
#endif
|