Skip to content

Commit

Permalink
QUIC CHANNEL, PORT: Abstract time retrieval
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #22674)
  • Loading branch information
hlandau committed Dec 21, 2023
1 parent 34fa182 commit f98bc5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions include/internal/quic_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 2 additions & 5 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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. */
Expand Down
10 changes: 7 additions & 3 deletions ssl/quic/quic_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* ====================================
Expand Down

0 comments on commit f98bc5c

Please sign in to comment.