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

lib/isc/netmgr/http.c
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/netmgr.c

index e8cd05c21c452005d87375367d37f5f8ae19f388..9febb627fcf89e8f453a65069b1b7d6ded0278ee 100644 (file)
@@ -18,6 +18,7 @@
 #include <signal.h>
 #include <string.h>
 
+#include <isc/async.h>
 #include <isc/base64.h>
 #include <isc/log.h>
 #include <isc/netmgr.h>
@@ -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
index 2010a4d43f26a8308ff1a67674afcb08e7606289..86cb9000a9fd7a5cd62bc91a5978374bfd64e6b7 100644 (file)
@@ -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 */
 
index e18767d29cc53bd9bfbf9b6917e31ed2b153d140..dc2c3354128b72a53c73f0b18ecd7e83e4dcd5ab 100644 (file)
@@ -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 */