From ffce2946c7f59ad14ffeeef16a82bf7f04e8cd9c Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Tue, 21 Feb 2023 10:18:59 +0000 Subject: Switch to using ossl_crypto_mutex from CRYPTO_RWLOCK Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/20348) --- ssl/quic/quic_impl.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'ssl/quic/quic_impl.c') diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 4286c526b7..b478e7c4f2 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -112,14 +112,15 @@ static ossl_inline int expect_quic_conn(const QUIC_CONNECTION *qc) */ static int quic_lock(QUIC_CONNECTION *qc) { - return CRYPTO_THREAD_write_lock(qc->mutex); + ossl_crypto_mutex_lock(qc->mutex); + return 1; } /* Precondition: Channel mutex is held (unchecked) */ QUIC_NEEDS_LOCK static void quic_unlock(QUIC_CONNECTION *qc) { - CRYPTO_THREAD_unlock(qc->mutex); + ossl_crypto_mutex_unlock(qc->mutex); } @@ -158,7 +159,7 @@ SSL *ossl_quic_new(SSL_CTX *ctx) if (qc->tls == NULL || (sc = SSL_CONNECTION_FROM_SSL(qc->tls)) == NULL) goto err; - if ((qc->mutex = CRYPTO_THREAD_lock_new()) == NULL) + if ((qc->mutex = ossl_crypto_mutex_new()) == NULL) goto err; qc->is_thread_assisted @@ -200,7 +201,7 @@ void ossl_quic_free(SSL *s) /* Note: SSL_free calls OPENSSL_free(qc) for us */ SSL_free(qc->tls); - CRYPTO_THREAD_lock_free(qc->mutex); + ossl_crypto_mutex_free(&qc->mutex); } /* SSL method init */ @@ -681,6 +682,7 @@ static int ensure_channel(QUIC_CONNECTION *qc) args.propq = qc->ssl.ctx->propq; args.is_server = 0; args.tls = qc->tls; + args.mutex = qc->mutex; qc->ch = ossl_quic_channel_new(&args); if (qc->ch == NULL) @@ -697,21 +699,23 @@ static int ensure_channel(QUIC_CONNECTION *qc) QUIC_NEEDS_LOCK static int ensure_channel_and_start(QUIC_CONNECTION *qc) { - if (!ensure_channel(qc)) - return 0; - - if (!configure_channel(qc) - || !ossl_quic_channel_start(qc->ch)) - goto err; + if (!qc->started) { + if (!ensure_channel(qc)) + return 0; - qc->stream0 = ossl_quic_channel_get_stream_by_id(qc->ch, 0); - if (qc->stream0 == NULL) - goto err; + if (!configure_channel(qc) + || !ossl_quic_channel_start(qc->ch)) + goto err; - if (qc->is_thread_assisted) - if (!ossl_quic_thread_assist_init_start(&qc->thread_assist, qc->ch)) + qc->stream0 = ossl_quic_channel_get_stream_by_id(qc->ch, 0); + if (qc->stream0 == NULL) goto err; + if (qc->is_thread_assisted) + if (!ossl_quic_thread_assist_init_start(&qc->thread_assist, qc->ch)) + goto err; + } + qc->started = 1; return 1; -- cgit v1.2.3