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

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

index 9febb627fcf89e8f453a65069b1b7d6ded0278ee..5e88c866af5253a968b7014299cb6002e5f7bff2 100644 (file)
@@ -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 {
index 86cb9000a9fd7a5cd62bc91a5978374bfd64e6b7..26ed2ddacf61b539a3897d78160fd0366def0d63 100644 (file)
@@ -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 */
 
index dc2c3354128b72a53c73f0b18ecd7e83e4dcd5ab..bb45f5e83d1a1a9fed40a81a2572533f936e8add 100644 (file)
@@ -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 */