diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-02-21 11:18:58 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-03-30 12:14:07 +0200 |
commit | fb2245c44b58b41a378eb47422221edd49ba9091 (patch) | |
tree | 7e7b828e8f62868f2cb93834b99f0618432a73dd /include | |
parent | QUIC Reactor: Allow a mutex to be released during waits (diff) | |
download | openssl-fb2245c44b58b41a378eb47422221edd49ba9091.tar.xz openssl-fb2245c44b58b41a378eb47422221edd49ba9091.zip |
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 'include')
-rw-r--r-- | include/internal/quic_channel.h | 36 | ||||
-rw-r--r-- | include/internal/quic_ssl.h | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/include/internal/quic_channel.h b/include/internal/quic_channel.h index f08252d1f9..13cd83bff1 100644 --- a/include/internal/quic_channel.h +++ b/include/internal/quic_channel.h @@ -47,6 +47,16 @@ * demuxers). Since we only use server-side functionality for dummy test servers * for now, which only need to handle one connection at a time, this is not * currently modelled. + * + * Synchronisation + * --------------- + * + * To support thread assisted mode, QUIC_CHANNEL can be used by multiple + * threads. **It is the caller's responsibility to ensure that the QUIC_CHANNEL + * is only accessed (whether via its methods or via direct access to its state) + * while the QUIC_CHANNEL mutex is held**, except for methods explicitly marked + * as not requiring prior locking. See ossl_quic_channel_get_mutex() for more + * information. This is an unchecked precondition. */ # define QUIC_CHANNEL_STATE_IDLE 0 @@ -198,6 +208,32 @@ QUIC_DEMUX *ossl_quic_channel_get0_demux(QUIC_CHANNEL *ch); SSL *ossl_quic_channel_get0_ssl(QUIC_CHANNEL *ch); +/* + * Retreves the channel mutex, which can be used to synchronise access to + * channel functions and internal data. In order to allow locks to be acquired + * and released with the correct granularity, it is the caller's responsibility + * to ensure this lock is held for write while calling any QUIC_CHANNEL method. + * + * This method is thread safe and does not require prior locking. It can also be + * called while the lock is already held. + */ +CRYPTO_RWLOCK *ossl_quic_channel_get_mutex(QUIC_CHANNEL *ch); + +/* + * Locks the channel mutex. It is roughly analagous to locking the mutex + * returned by ossl_quic_channel_get_mutex() but might be able to avoid locking + * where thread assisted mode is not being used, thus it is recommended that + * these methods are used uniformly rather than locking the channel mutex + * directly. + * + * This method is (obviously) thread safe and does not require prior locking. It + * must not be called while the lock is already held. + */ +int ossl_quic_channel_lock(QUIC_CHANNEL *ch); + +/* Unlocks the channel mutex. */ +void ossl_quic_channel_unlock(QUIC_CHANNEL *ch); + # endif #endif diff --git a/include/internal/quic_ssl.h b/include/internal/quic_ssl.h index 7b89534c22..3cf32e0944 100644 --- a/include/internal/quic_ssl.h +++ b/include/internal/quic_ssl.h @@ -46,6 +46,7 @@ void ossl_quic_set_accept_state(QUIC_CONNECTION *qc); __owur int ossl_quic_has_pending(const QUIC_CONNECTION *qc); __owur int ossl_quic_tick(QUIC_CONNECTION *qc); __owur int ossl_quic_get_tick_timeout(QUIC_CONNECTION *qc, struct timeval *tv); +OSSL_TIME ossl_quic_get_tick_deadline(QUIC_CONNECTION *qc); __owur int ossl_quic_get_rpoll_descriptor(QUIC_CONNECTION *qc, BIO_POLL_DESCRIPTOR *d); __owur int ossl_quic_get_wpoll_descriptor(QUIC_CONNECTION *qc, BIO_POLL_DESCRIPTOR *d); __owur int ossl_quic_get_net_read_desired(QUIC_CONNECTION *qc); |