From f98bc5c95b7389015e11cd2102e2a6a09b3c9e36 Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Thu, 9 Nov 2023 10:27:13 +0000 Subject: [PATCH] QUIC CHANNEL, PORT: Abstract time retrieval Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22674) --- include/internal/quic_port.h | 3 +++ ssl/quic/quic_channel.c | 7 ++----- ssl/quic/quic_port.c | 10 +++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/internal/quic_port.h b/include/internal/quic_port.h index a42d2138f56..86614d607c7 100644 --- a/include/internal/quic_port.h +++ b/include/internal/quic_port.h @@ -80,6 +80,9 @@ QUIC_DEMUX *ossl_quic_port_get0_demux(QUIC_PORT *port); /* Gets the mutex used by the port. */ CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port); +/* Gets the current time. */ +OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port); + # endif #endif diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c index e266a552e39..02ef8454967 100644 --- a/ssl/quic/quic_channel.c +++ b/ssl/quic/quic_channel.c @@ -692,7 +692,7 @@ QUIC_PORT *ossl_quic_channel_get0_port(QUIC_CHANNEL *ch) CRYPTO_MUTEX *ossl_quic_channel_get_mutex(QUIC_CHANNEL *ch) { - return ch->port->mutex; + return ossl_quic_port_get0_mutex(ch->port); } int ossl_quic_channel_has_pending(const QUIC_CHANNEL *ch) @@ -711,10 +711,7 @@ static OSSL_TIME get_time(void *arg) { QUIC_CHANNEL *ch = arg; - if (ch->port->now_cb == NULL) - return ossl_time_now(); - - return ch->port->now_cb(ch->port->now_cb_arg); + return ossl_quic_port_get_time(ch->port); } /* Used by QSM. */ diff --git a/ssl/quic/quic_port.c b/ssl/quic/quic_port.c index a5858d009ac..0beb69835bb 100644 --- a/ssl/quic/quic_port.c +++ b/ssl/quic/quic_port.c @@ -101,16 +101,20 @@ CRYPTO_MUTEX *ossl_quic_port_get0_mutex(QUIC_PORT *port) return port->mutex; } -static OSSL_TIME get_time(void *arg) +OSSL_TIME ossl_quic_port_get_time(QUIC_PORT *port) { - QUIC_PORT *port = arg; - if (port->now_cb == NULL) return ossl_time_now(); return port->now_cb(port->now_cb_arg); } +static OSSL_TIME get_time(void *port) +{ + return ossl_quic_port_get_time(port); +} + + /* * QUIC Port: Network BIO Configuration * ==================================== -- 2.47.2