# 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
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.
*/
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);
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
* =============================
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;
}
* 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;
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)
return 1;
}
+RIO_NOTIFIER *ossl_quic_reactor_get0_notifier(QUIC_REACTOR *rtor)
+{
+ return rtor->have_notifier ? &rtor->notifier : NULL;
+}
+
/*
* Blocking I/O Adaptation Layer
* =============================