summaryrefslogtreecommitdiff
path: root/ssl/quic
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-02-21 10:18:58 +0000
committerHugo Landau <hlandau@openssl.org>2023-03-30 11:14:07 +0100
commitfb2245c44b58b41a378eb47422221edd49ba9091 (patch)
tree7e7b828e8f62868f2cb93834b99f0618432a73dd /ssl/quic
parentc019e1efe9b5dbb43c52f516e76b3f535158aaae (diff)
downloadopenssl-new-fb2245c44b58b41a378eb47422221edd49ba9091.tar.gz
QUIC Channel: Add a mutex
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')
-rw-r--r--ssl/quic/quic_channel.c20
-rw-r--r--ssl/quic/quic_channel_local.h6
2 files changed, 26 insertions, 0 deletions
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c
index 86eed313ab..efe8ca6def 100644
--- a/ssl/quic/quic_channel.c
+++ b/ssl/quic/quic_channel.c
@@ -115,6 +115,10 @@ static int ch_init(QUIC_CHANNEL *ch)
qtx_args.mdpl = QUIC_MIN_INITIAL_DGRAM_LEN;
ch->rx_max_udp_payload_size = qtx_args.mdpl;
+ ch->mutex = CRYPTO_THREAD_lock_new();
+ if (ch->mutex == NULL)
+ goto err;
+
ch->qtx = ossl_qtx_new(&qtx_args);
if (ch->qtx == NULL)
goto err;
@@ -318,6 +322,7 @@ static void ch_cleanup(QUIC_CHANNEL *ch)
ossl_qrx_free(ch->qrx);
ossl_quic_demux_free(ch->demux);
OPENSSL_free(ch->local_transport_params);
+ CRYPTO_THREAD_lock_free(ch->mutex);
}
QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args)
@@ -443,6 +448,21 @@ QUIC_DEMUX *ossl_quic_channel_get0_demux(QUIC_CHANNEL *ch)
return ch->demux;
}
+CRYPTO_MUTEX *ossl_quic_channel_get_mutex(QUIC_CHANNEL *ch)
+{
+ return ch->mutex;
+}
+
+int ossl_quic_channel_lock(QUIC_CHANNEL *ch)
+{
+ return ossl_crypto_mutex_lock(ch->mutex);
+}
+
+void ossl_quic_channel_unlock(QUIC_CHANNEL *ch)
+{
+ ossl_crypto_mutex_unlock(ch->mutex);
+}
+
/*
* QUIC Channel: Callbacks from Miscellaneous Subsidiary Components
* ================================================================
diff --git a/ssl/quic/quic_channel_local.h b/ssl/quic/quic_channel_local.h
index fa2618bce5..2f63119cef 100644
--- a/ssl/quic/quic_channel_local.h
+++ b/ssl/quic/quic_channel_local.h
@@ -26,6 +26,12 @@ struct quic_channel_st {
const char *propq;
/*
+ * Master synchronisation mutex used for thread assisted mode
+ * synchronisation.
+ */
+ CRYPTO_RWLOCK *mutex;
+
+ /*
* The associated TLS 1.3 connection data. Used to provide the handshake
* layer; its 'network' side is plugged into the crypto stream for each EL
* (other than the 0-RTT EL).