From 35b4ef0a08fa7916559c4bc25e34a46a9378cae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 23 Mar 2023 22:46:58 +0100 Subject: [PATCH] Convert sending on the TLS socket to to isc_async callback Simplify the sending on the TLS socket by using the isc_async API from the loopmgr instead of using the asychronous netievent mechanism in the netmgr. --- lib/isc/netmgr/netmgr-int.h | 8 -------- lib/isc/netmgr/netmgr.c | 3 --- lib/isc/netmgr/tlsstream.c | 23 ++++++++--------------- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 96307c7e5d..4283ac062c 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -250,7 +250,6 @@ struct isc_nmhandle { }; typedef enum isc__netievent_type { - netievent_tlssend, netievent_tlsconnect, netievent_tlsdobio, @@ -1286,9 +1285,6 @@ isc__nm_tcp_senddns(isc_nmhandle_t *handle, const isc_region_t *region, * ahead of data (two bytes (16 bit) in big-endian format). */ -void -isc__nm_async_tlssend(isc__networker_t *worker, isc__netievent_t *ev0); - void isc__nm_async_tlsdobio(isc__networker_t *worker, isc__netievent_t *ev0); @@ -1677,8 +1673,6 @@ NETIEVENT_SOCKET_TYPE(httpclose); NETIEVENT_SOCKET_HTTP_EPS_TYPE(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ -NETIEVENT_SOCKET_REQ_TYPE(tlssend); - NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb); NETIEVENT_SOCKET_TYPE(streamdnsread); @@ -1698,8 +1692,6 @@ NETIEVENT_SOCKET_DECL(httpclose); NETIEVENT_SOCKET_HTTP_EPS_DECL(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ -NETIEVENT_SOCKET_REQ_DECL(tlssend); - NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb); NETIEVENT_SOCKET_DECL(streamdnsread); diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 3579f9f95d..bc4f50f8d9 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -439,7 +439,6 @@ process_netievent(void *arg) { isc__networker_t *worker = ievent->worker; switch (ievent->type) { - NETIEVENT_CASE(tlssend); NETIEVENT_CASE(tlsdobio); #if HAVE_LIBNGHTTP2 NETIEVENT_CASE(httpsend); @@ -484,8 +483,6 @@ NETIEVENT_SOCKET_DEF(httpclose); NETIEVENT_SOCKET_HTTP_EPS_DEF(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ -NETIEVENT_SOCKET_REQ_DEF(tlssend); - NETIEVENT_SOCKET_DEF(streamdnsread); NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel); diff --git a/lib/isc/netmgr/tlsstream.c b/lib/isc/netmgr/tlsstream.c index 8e686be5e3..6010a2b860 100644 --- a/lib/isc/netmgr/tlsstream.c +++ b/lib/isc/netmgr/tlsstream.c @@ -948,19 +948,17 @@ isc_nm_listentls(isc_nm_t *mgr, uint32_t workers, isc_sockaddr_t *iface, return (result); } -void -isc__nm_async_tlssend(isc__networker_t *worker, isc__netievent_t *ev0) { - isc__netievent_tlssend_t *ievent = (isc__netievent_tlssend_t *)ev0; - isc_nmsocket_t *sock = ievent->sock; - isc__nm_uvreq_t *req = ievent->req; +static void +tls_send_direct(void *arg) { + isc__nm_uvreq_t *req = arg; REQUIRE(VALID_UVREQ(req)); + + isc_nmsocket_t *sock = req->sock; + + REQUIRE(VALID_NMSOCK(sock)); REQUIRE(sock->tid == isc_tid()); - UNUSED(worker); - - ievent->req = NULL; - if (inactive(sock)) { req->cb.send(req->handle, ISC_R_CANCELED, req->cbarg); goto done; @@ -975,7 +973,6 @@ done: static void tls_send(isc_nmhandle_t *handle, const isc_region_t *region, isc_nm_cb_t cb, void *cbarg, const bool dnsmsg) { - isc__netievent_tlssend_t *ievent = NULL; isc__nm_uvreq_t *uvreq = NULL; isc_nmsocket_t *sock = NULL; @@ -996,11 +993,7 @@ tls_send(isc_nmhandle_t *handle, const isc_region_t *region, isc_nm_cb_t cb, *(uint16_t *)uvreq->tcplen = htons(region->length); } - /* - * We need to create an event and pass it using async channel - */ - ievent = isc__nm_get_netievent_tlssend(sock->worker, sock, uvreq); - isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent); + isc_async_run(sock->worker->loop, tls_send_direct, uvreq); } void