From: Ondřej Surý Date: Thu, 23 Mar 2023 22:00:21 +0000 (+0100) Subject: Convert sending on the DoH socket to to isc_async callback X-Git-Tag: v9.19.12~66^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=115160de73410ef3f727faf1c5d5981f8e47e24a;p=thirdparty%2Fbind9.git Convert sending on the DoH socket to to isc_async callback Simplify the sending on the DoH socket by using the isc_async API from the loopmgr instead of using the asychronous netievent mechanism in the netmgr. --- diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 9febb627fcf..5e88c866af5 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -2157,11 +2157,13 @@ error: return (0); } +static void +http_send_cb(void *arg); + void isc__nm_http_send(isc_nmhandle_t *handle, const isc_region_t *region, isc_nm_cb_t cb, void *cbarg) { isc_nmsocket_t *sock = NULL; - isc__netievent_httpsend_t *ievent = NULL; isc__nm_uvreq_t *uvreq = NULL; REQUIRE(VALID_NMHANDLE(handle)); @@ -2179,8 +2181,7 @@ isc__nm_http_send(isc_nmhandle_t *handle, const isc_region_t *region, uvreq->uvbuf.base = (char *)region->base; uvreq->uvbuf.len = region->length; - ievent = isc__nm_get_netievent_httpsend(sock->worker, sock, uvreq); - isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent); + isc_async_run(sock->worker->loop, http_send_cb, uvreq); } static void @@ -2270,26 +2271,22 @@ server_httpsend(isc_nmhandle_t *handle, isc_nmsocket_t *sock, isc__nm_uvreq_put(&req, sock); } -void -isc__nm_async_httpsend(isc__networker_t *worker, isc__netievent_t *ev0) { - isc__netievent_httpsend_t *ievent = (isc__netievent_httpsend_t *)ev0; - isc_nmsocket_t *sock = ievent->sock; - isc__nm_uvreq_t *req = ievent->req; - isc_nmhandle_t *handle = NULL; - isc_nm_http_session_t *session = NULL; +static void +http_send_cb(void *arg) { + isc__nm_uvreq_t *req = arg; - UNUSED(worker); + REQUIRE(VALID_UVREQ(req)); + + isc_nmsocket_t *sock = req->sock; REQUIRE(VALID_NMSOCK(sock)); - REQUIRE(VALID_UVREQ(req)); REQUIRE(VALID_HTTP2_SESSION(sock->h2.session)); - ievent->req = NULL; - handle = req->handle; + isc_nmhandle_t *handle = req->handle; REQUIRE(VALID_NMHANDLE(handle)); - session = sock->h2.session; + isc_nm_http_session_t *session = sock->h2.session; if (session != NULL && session->client) { client_httpsend(handle, sock, req); } else { diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 86cb9000a9f..26ed2ddacf6 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_httpsend, netievent_httpendpoints, netievent_streamdnsread, @@ -1427,9 +1426,6 @@ isc__nm_http_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl); const char * isc__nm_http_verify_tls_peer_result_string(const isc_nmhandle_t *handle); -void -isc__nm_async_httpsend(isc__networker_t *worker, isc__netievent_t *ev0); - void isc__nm_async_httpendpoints(isc__networker_t *worker, isc__netievent_t *ev0); @@ -1646,7 +1642,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener); */ #ifdef HAVE_LIBNGHTTP2 -NETIEVENT_SOCKET_REQ_TYPE(httpsend); NETIEVENT_SOCKET_HTTP_EPS_TYPE(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ @@ -1661,7 +1656,6 @@ NETIEVENT_SOCKET_TYPE(sockstop); /* Now declared the helper functions */ #ifdef HAVE_LIBNGHTTP2 -NETIEVENT_SOCKET_REQ_DECL(httpsend); NETIEVENT_SOCKET_HTTP_EPS_DECL(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index dc2c3354128..bb45f5e83d1 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -440,7 +440,6 @@ process_netievent(void *arg) { switch (ievent->type) { #if HAVE_LIBNGHTTP2 - NETIEVENT_CASE(httpsend); NETIEVENT_CASE(httpendpoints); #endif NETIEVENT_CASE(streamdnsread); @@ -473,7 +472,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) { } #ifdef HAVE_LIBNGHTTP2 -NETIEVENT_SOCKET_REQ_DEF(httpsend); NETIEVENT_SOCKET_HTTP_EPS_DEF(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */