From 643d1496966cf044def833d1528e7b27542a3cda Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Mon, 13 May 2024 20:20:23 +0100 Subject: [PATCH] QUIC APL: Add support for registering blocking operations to support polling code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Matt Caswell Reviewed-by: Saša Nedvědický Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/25416) --- include/internal/quic_ssl.h | 3 +++ ssl/quic/quic_impl.c | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/internal/quic_ssl.h b/include/internal/quic_ssl.h index 2848945cd40..a470d146575 100644 --- a/include/internal/quic_ssl.h +++ b/include/internal/quic_ssl.h @@ -153,6 +153,9 @@ int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title); /* APIs used by the polling infrastructure */ int ossl_quic_conn_poll_events(SSL *ssl, uint64_t events, int do_tick, uint64_t *revents); +int ossl_quic_get_notifier_fd(SSL *ssl); +void ossl_quic_enter_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx); +void ossl_quic_leave_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx); # endif diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 3d05acff2bd..0b4252eae3f 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -18,6 +18,7 @@ #include "internal/quic_error.h" #include "internal/quic_engine.h" #include "internal/quic_port.h" +#include "internal/quic_reactor_wait_ctx.h" #include "internal/time.h" typedef struct qctx_st QCTX; @@ -4831,6 +4832,47 @@ int ossl_quic_conn_poll_events(SSL *ssl, uint64_t events, int do_tick, return 1; } +int ossl_quic_get_notifier_fd(SSL *ssl) +{ + QCTX ctx; + QUIC_REACTOR *rtor; + RIO_NOTIFIER *nfy; + + if (!expect_quic_any(ssl, &ctx)) + return -1; + + rtor = ossl_quic_obj_get0_reactor(ctx.obj); + nfy = ossl_quic_reactor_get0_notifier(rtor); + if (nfy == NULL) + return -1; + + return ossl_rio_notifier_as_fd(nfy); +} + +void ossl_quic_enter_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx) +{ + QCTX ctx; + QUIC_REACTOR *rtor; + + if (!expect_quic_any(ssl, &ctx)) + return; + + rtor = ossl_quic_obj_get0_reactor(ctx.obj); + ossl_quic_reactor_wait_ctx_enter(wctx, rtor); +} + +void ossl_quic_leave_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx) +{ + QCTX ctx; + QUIC_REACTOR *rtor; + + if (!expect_quic_any(ssl, &ctx)) + return; + + rtor = ossl_quic_obj_get0_reactor(ctx.obj); + ossl_quic_reactor_wait_ctx_leave(wctx, rtor); +} + /* * Internal Testing APIs * ===================== -- 2.47.2