diff options
author | Pauli <pauli@openssl.org> | 2023-06-22 01:39:36 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-01 13:18:25 +0200 |
commit | 43a07d6dd44cc9594a6cfecc464b69a7c4142d5f (patch) | |
tree | 16e173a87ca3f5478d9c54a0b86427c8a0092492 /ssl/ssl_sess.c | |
parent | test: update to structure based atomics (diff) | |
download | openssl-43a07d6dd44cc9594a6cfecc464b69a7c4142d5f.tar.xz openssl-43a07d6dd44cc9594a6cfecc464b69a7c4142d5f.zip |
tls: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21260)
Diffstat (limited to 'ssl/ssl_sess.c')
-rw-r--r-- | ssl/ssl_sess.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 6d5e87f687..486d938c94 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -110,20 +110,17 @@ SSL_SESSION *SSL_SESSION_new(void) return NULL; ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */ - ss->references = 1; /* 5 minute timeout by default */ ss->timeout = ossl_seconds2time(60 * 5 + 4); ss->time = ossl_time_now(); ssl_session_calculate_timeout(ss); - ss->lock = CRYPTO_THREAD_lock_new(); - if (ss->lock == NULL) { - ERR_raise(ERR_LIB_SSL, ERR_R_CRYPTO_LIB); + if (!CRYPTO_NEW_REF(&ss->references, 1)) { OPENSSL_free(ss); return NULL; } if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data)) { - CRYPTO_THREAD_lock_free(ss->lock); + CRYPTO_FREE_REF(&ss->references); OPENSSL_free(ss); return NULL; } @@ -174,13 +171,8 @@ SSL_SESSION *ssl_session_dup(const SSL_SESSION *src, int ticket) dest->next = NULL; dest->owner = NULL; - dest->references = 1; - - dest->lock = CRYPTO_THREAD_lock_new(); - if (dest->lock == NULL) { - ERR_raise(ERR_LIB_SSL, ERR_R_CRYPTO_LIB); + if (!CRYPTO_NEW_REF(&dest->references, 1)) goto err; - } if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, dest, &dest->ex_data)) { ERR_raise(ERR_LIB_SSL, ERR_R_CRYPTO_LIB); @@ -821,7 +813,7 @@ void SSL_SESSION_free(SSL_SESSION *ss) if (ss == NULL) return; - CRYPTO_DOWN_REF(&ss->references, &i, ss->lock); + CRYPTO_DOWN_REF(&ss->references, &i); REF_PRINT_COUNT("SSL_SESSION", ss); if (i > 0) return; @@ -845,7 +837,7 @@ void SSL_SESSION_free(SSL_SESSION *ss) #endif OPENSSL_free(ss->ext.alpn_selected); OPENSSL_free(ss->ticket_appdata); - CRYPTO_THREAD_lock_free(ss->lock); + CRYPTO_FREE_REF(&ss->references); OPENSSL_clear_free(ss, sizeof(*ss)); } @@ -853,7 +845,7 @@ int SSL_SESSION_up_ref(SSL_SESSION *ss) { int i; - if (CRYPTO_UP_REF(&ss->references, &i, ss->lock) <= 0) + if (CRYPTO_UP_REF(&ss->references, &i) <= 0) return 0; REF_PRINT_COUNT("SSL_SESSION", ss); |