summaryrefslogtreecommitdiffstats
path: root/ssl/quic/quic_impl.c
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-02-21 10:18:59 +0000
committerHugo Landau <hlandau@openssl.org>2023-03-30 11:14:08 +0100
commitffce2946c7f59ad14ffeeef16a82bf7f04e8cd9c (patch)
tree051a4ffc534aea4f40035722d5cea256e7b01cd6 /ssl/quic/quic_impl.c
parentccd31037713ad1cdfd88c85a169bd18b08579813 (diff)
Switch to using ossl_crypto_mutex from CRYPTO_RWLOCK
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20348)
Diffstat (limited to 'ssl/quic/quic_impl.c')
-rw-r--r--ssl/quic/quic_impl.c34
1 files changed, 19 insertions, 15 deletions
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;