From: Ondřej Surý Date: Thu, 23 Mar 2023 21:56:00 +0000 (+0100) Subject: Convert closing the DoH socket to to isc_async callback X-Git-Tag: v9.19.12~66^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a321d3f419dedcad1bd979078bd9344895b83586;p=thirdparty%2Fbind9.git Convert closing the DoH socket to to isc_async callback Simplify the closing 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 e8cd05c21c4..9febb627fcf 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -2725,6 +2726,15 @@ http_close_direct(isc_nmsocket_t *sock) { } } +static void +http_close_cb(void *arg) { + isc_nmsocket_t *sock = arg; + REQUIRE(VALID_NMSOCK(sock)); + + http_close_direct(sock); + isc__nmsocket_detach(&sock); +} + void isc__nm_http_close(isc_nmsocket_t *sock) { bool destroy = false; @@ -2753,23 +2763,8 @@ isc__nm_http_close(isc_nmsocket_t *sock) { return; } - isc__netievent_httpclose_t *ievent = - isc__nm_get_netievent_httpclose(sock->worker, sock); - - isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent); -} - -void -isc__nm_async_httpclose(isc__networker_t *worker, isc__netievent_t *ev0) { - isc__netievent_httpclose_t *ievent = (isc__netievent_httpclose_t *)ev0; - isc_nmsocket_t *sock = ievent->sock; - - REQUIRE(VALID_NMSOCK(sock)); - REQUIRE(sock->tid == isc_tid()); - - UNUSED(worker); - - http_close_direct(sock); + isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL }); + isc_async_run(sock->worker->loop, http_close_cb, sock); } static void diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 2010a4d43f2..86cb9000a9f 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_httpclose, netievent_httpsend, netievent_httpendpoints, @@ -1431,9 +1430,6 @@ 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_httpclose(isc__networker_t *worker, isc__netievent_t *ev0); - void isc__nm_async_httpendpoints(isc__networker_t *worker, isc__netievent_t *ev0); @@ -1651,7 +1647,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener); #ifdef HAVE_LIBNGHTTP2 NETIEVENT_SOCKET_REQ_TYPE(httpsend); -NETIEVENT_SOCKET_TYPE(httpclose); NETIEVENT_SOCKET_HTTP_EPS_TYPE(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ @@ -1667,7 +1662,6 @@ NETIEVENT_SOCKET_TYPE(sockstop); #ifdef HAVE_LIBNGHTTP2 NETIEVENT_SOCKET_REQ_DECL(httpsend); -NETIEVENT_SOCKET_DECL(httpclose); NETIEVENT_SOCKET_HTTP_EPS_DECL(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */ diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index e18767d29cc..dc2c3354128 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -441,7 +441,6 @@ process_netievent(void *arg) { switch (ievent->type) { #if HAVE_LIBNGHTTP2 NETIEVENT_CASE(httpsend); - NETIEVENT_CASE(httpclose); NETIEVENT_CASE(httpendpoints); #endif NETIEVENT_CASE(streamdnsread); @@ -475,7 +474,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) { #ifdef HAVE_LIBNGHTTP2 NETIEVENT_SOCKET_REQ_DEF(httpsend); -NETIEVENT_SOCKET_DEF(httpclose); NETIEVENT_SOCKET_HTTP_EPS_DEF(httpendpoints); #endif /* HAVE_LIBNGHTTP2 */