]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Convert sending on the TLS socket to to isc_async callback
authorOndřej Surý <ondrej@isc.org>
Thu, 23 Mar 2023 21:46:58 +0000 (22:46 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 24 Mar 2023 06:58:52 +0000 (07:58 +0100)
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
lib/isc/netmgr/netmgr.c
lib/isc/netmgr/tlsstream.c

index 96307c7e5d40e7c1d205fec8505ab627e80e4be6..4283ac062c2cc559d81a82c1799430ac35100553 100644 (file)
@@ -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);
index 3579f9f95d4b3a3249396922035073e018c5b58d..bc4f50f8d9f44ec9fd0156f638b049768ad919b6 100644 (file)
@@ -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);
 
index 8e686be5e350d9e0793c9fb6b0772e6517cc5751..6010a2b8609520deb1f6d149f715ea8268696cb9 100644 (file)
@@ -948,18 +948,16 @@ 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));
-       REQUIRE(sock->tid == isc_tid());
 
-       UNUSED(worker);
+       isc_nmsocket_t *sock = req->sock;
 
-       ievent->req = NULL;
+       REQUIRE(VALID_NMSOCK(sock));
+       REQUIRE(sock->tid == isc_tid());
 
        if (inactive(sock)) {
                req->cb.send(req->handle, ISC_R_CANCELED, req->cbarg);
@@ -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