QUIC REACTOR: Integrate RIO NOTIFIER
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> (Merged from https://github.com/openssl/openssl/pull/24971)
This commit is contained in:
parent
14516cd5a4
commit
6bc47aa65f
3 changed files with 54 additions and 11 deletions
|
@ -13,6 +13,7 @@
|
|||
# include "internal/sockets.h"
|
||||
# include "internal/quic_predef.h"
|
||||
# include "internal/thread_arch.h"
|
||||
# include "internal/rio_notifier.h"
|
||||
# include <openssl/bio.h>
|
||||
|
||||
# ifndef OPENSSL_NO_QUIC
|
||||
|
@ -99,6 +100,9 @@ struct quic_reactor_st {
|
|||
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg, uint32_t flags);
|
||||
void *tick_cb_arg;
|
||||
|
||||
/* Used to notify other threads. */
|
||||
RIO_NOTIFIER notifier;
|
||||
|
||||
/*
|
||||
* These are true if we would like to know when we can read or write from
|
||||
* the network respectively.
|
||||
|
@ -112,13 +116,22 @@ struct quic_reactor_st {
|
|||
*/
|
||||
unsigned int can_poll_r : 1;
|
||||
unsigned int can_poll_w : 1;
|
||||
|
||||
/* 1 if notifier is present and initialised. */
|
||||
unsigned int have_notifier : 1;
|
||||
};
|
||||
|
||||
void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
|
||||
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg,
|
||||
uint32_t flags),
|
||||
void *tick_cb_arg,
|
||||
OSSL_TIME initial_tick_deadline);
|
||||
/* Create an OS notifier? */
|
||||
#define QUIC_REACTOR_FLAG_USE_NOTIFIER (1U << 0)
|
||||
|
||||
int ossl_quic_reactor_init(QUIC_REACTOR *rtor,
|
||||
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg,
|
||||
uint32_t flags),
|
||||
void *tick_cb_arg,
|
||||
OSSL_TIME initial_tick_deadline,
|
||||
uint64_t flags);
|
||||
|
||||
void ossl_quic_reactor_cleanup(QUIC_REACTOR *rtor);
|
||||
|
||||
void ossl_quic_reactor_set_poll_r(QUIC_REACTOR *rtor,
|
||||
const BIO_POLL_DESCRIPTOR *r);
|
||||
|
@ -152,6 +165,8 @@ OSSL_TIME ossl_quic_reactor_get_tick_deadline(QUIC_REACTOR *rtor);
|
|||
|
||||
int ossl_quic_reactor_tick(QUIC_REACTOR *rtor, uint32_t flags);
|
||||
|
||||
RIO_NOTIFIER *ossl_quic_reactor_get0_notifier(QUIC_REACTOR *rtor);
|
||||
|
||||
/*
|
||||
* Blocking I/O Adaptation Layer
|
||||
* =============================
|
||||
|
|
|
@ -55,7 +55,7 @@ void ossl_quic_engine_free(QUIC_ENGINE *qeng)
|
|||
|
||||
static int qeng_init(QUIC_ENGINE *qeng)
|
||||
{
|
||||
ossl_quic_reactor_init(&qeng->rtor, qeng_tick, qeng, ossl_time_zero());
|
||||
ossl_quic_reactor_init(&qeng->rtor, qeng_tick, qeng, ossl_time_zero(), 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
* Core I/O Reactor Framework
|
||||
* ==========================
|
||||
*/
|
||||
void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
|
||||
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg,
|
||||
uint32_t flags),
|
||||
void *tick_cb_arg,
|
||||
OSSL_TIME initial_tick_deadline)
|
||||
int ossl_quic_reactor_init(QUIC_REACTOR *rtor,
|
||||
void (*tick_cb)(QUIC_TICK_RESULT *res, void *arg,
|
||||
uint32_t flags),
|
||||
void *tick_cb_arg,
|
||||
OSSL_TIME initial_tick_deadline,
|
||||
uint64_t flags)
|
||||
{
|
||||
rtor->poll_r.type = BIO_POLL_DESCRIPTOR_TYPE_NONE;
|
||||
rtor->poll_w.type = BIO_POLL_DESCRIPTOR_TYPE_NONE;
|
||||
|
@ -30,6 +31,28 @@ void ossl_quic_reactor_init(QUIC_REACTOR *rtor,
|
|||
|
||||
rtor->tick_cb = tick_cb;
|
||||
rtor->tick_cb_arg = tick_cb_arg;
|
||||
|
||||
if ((flags & QUIC_REACTOR_FLAG_USE_NOTIFIER) != 0) {
|
||||
if (!ossl_rio_notifier_init(&rtor->notifier))
|
||||
return 0;
|
||||
|
||||
rtor->have_notifier = 1;
|
||||
} else {
|
||||
rtor->have_notifier = 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ossl_quic_reactor_cleanup(QUIC_REACTOR *rtor)
|
||||
{
|
||||
if (rtor == NULL)
|
||||
return;
|
||||
|
||||
if (rtor->have_notifier) {
|
||||
ossl_rio_notifier_cleanup(&rtor->notifier);
|
||||
rtor->have_notifier = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ossl_quic_reactor_set_poll_r(QUIC_REACTOR *rtor, const BIO_POLL_DESCRIPTOR *r)
|
||||
|
@ -114,6 +137,11 @@ int ossl_quic_reactor_tick(QUIC_REACTOR *rtor, uint32_t flags)
|
|||
return 1;
|
||||
}
|
||||
|
||||
RIO_NOTIFIER *ossl_quic_reactor_get0_notifier(QUIC_REACTOR *rtor)
|
||||
{
|
||||
return rtor->have_notifier ? &rtor->notifier : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Blocking I/O Adaptation Layer
|
||||
* =============================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue