]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Convert setting of the DoH endpoints to to isc_async callback
authorOndřej Surý <ondrej@isc.org>
Thu, 23 Mar 2023 22:20:33 +0000 (23:20 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 24 Mar 2023 06:58:52 +0000 (07:58 +0100)
Simplify the setting of the DoH endpoints 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 5e88c866af5253a968b7014299cb6002e5f7bff2..65d57929f936b18cb9f64c31c7978a94bb4e02e1 100644 (file)
@@ -2956,6 +2956,29 @@ isc__nm_http_set_max_streams(isc_nmsocket_t *listener,
        atomic_store(&listener->h2.max_concurrent_streams, max_streams);
 }
 
+typedef struct http_endpoints_data {
+       isc_nmsocket_t *listener;
+       isc_nm_http_endpoints_t *endpoints;
+} http_endpoints_data_t;
+
+static void
+http_set_endpoints_cb(void *arg) {
+       http_endpoints_data_t *data = arg;
+       const int tid = isc_tid();
+       isc_nmsocket_t *listener = data->listener;
+       isc_nm_http_endpoints_t *endpoints = data->endpoints;
+       isc__networker_t *worker = &listener->worker->netmgr->workers[tid];
+
+       isc_mem_put(worker->loop->mctx, data, sizeof(*data));
+
+       isc_nm_http_endpoints_detach(&listener->h2.listener_endpoints[tid]);
+       isc_nm_http_endpoints_attach(endpoints,
+                                    &listener->h2.listener_endpoints[tid]);
+
+       isc_nm_http_endpoints_detach(&endpoints);
+       isc__nmsocket_detach(&listener);
+}
+
 void
 isc_nm_http_set_endpoints(isc_nmsocket_t *listener,
                          isc_nm_http_endpoints_t *eps) {
@@ -2970,27 +2993,16 @@ isc_nm_http_set_endpoints(isc_nmsocket_t *listener,
        atomic_store(&eps->in_use, true);
 
        for (size_t i = 0; i < isc_loopmgr_nloops(loopmgr); i++) {
-               isc__netievent__http_eps_t *ievent =
-                       isc__nm_get_netievent_httpendpoints(
-                               &listener->worker->netmgr->workers[i], listener,
-                               eps);
-               isc__nm_enqueue_ievent(&listener->worker->netmgr->workers[i],
-                                      (isc__netievent_t *)ievent);
-       }
-}
+               isc__networker_t *worker =
+                       &listener->worker->netmgr->workers[i];
+               http_endpoints_data_t *data = isc_mem_getx(
+                       worker->loop->mctx, sizeof(*data), ISC_MEM_ZERO);
 
-void
-isc__nm_async_httpendpoints(isc__networker_t *worker, isc__netievent_t *ev0) {
-       isc__netievent__http_eps_t *ievent = (isc__netievent__http_eps_t *)ev0;
-       const int tid = isc_tid();
-       isc_nmsocket_t *listener = ievent->sock;
-       isc_nm_http_endpoints_t *eps = ievent->endpoints;
+               isc__nmsocket_attach(listener, &data->listener);
+               isc_nm_http_endpoints_attach(eps, &data->endpoints);
 
-       UNUSED(worker);
-
-       isc_nm_http_endpoints_detach(&listener->h2.listener_endpoints[tid]);
-       isc_nm_http_endpoints_attach(eps,
-                                    &listener->h2.listener_endpoints[tid]);
+               isc_async_run(worker->loop, http_set_endpoints_cb, data);
+       }
 }
 
 static void
index 26ed2ddacf61b539a3897d78160fd0366def0d63..719b769f196ad68e5045a79663c58d3c34aa6e6b 100644 (file)
@@ -250,8 +250,6 @@ struct isc_nmhandle {
 };
 
 typedef enum isc__netievent_type {
-       netievent_httpendpoints,
-
        netievent_streamdnsread,
        netievent_streamdnscancel,
 
@@ -1426,9 +1424,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_httpendpoints(isc__networker_t *worker, isc__netievent_t *ev0);
-
 bool
 isc__nm_parse_httpquery(const char *query_string, const char **start,
                        size_t *len);
@@ -1641,10 +1636,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
  * typedef all the netievent types
  */
 
-#ifdef HAVE_LIBNGHTTP2
-NETIEVENT_SOCKET_HTTP_EPS_TYPE(httpendpoints);
-#endif /* HAVE_LIBNGHTTP2 */
-
 NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
 
 NETIEVENT_SOCKET_TYPE(streamdnsread);
@@ -1655,10 +1646,6 @@ NETIEVENT_SOCKET_TYPE(sockstop);
 
 /* Now declared the helper functions */
 
-#ifdef HAVE_LIBNGHTTP2
-NETIEVENT_SOCKET_HTTP_EPS_DECL(httpendpoints);
-#endif /* HAVE_LIBNGHTTP2 */
-
 NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
 
 NETIEVENT_SOCKET_DECL(streamdnsread);
index bb45f5e83d1a1a9fed40a81a2572533f936e8add..3c9f0458874798c0dcf9bfc768fcb9e86710007d 100644 (file)
@@ -439,9 +439,6 @@ process_netievent(void *arg) {
        isc__networker_t *worker = ievent->worker;
 
        switch (ievent->type) {
-#if HAVE_LIBNGHTTP2
-               NETIEVENT_CASE(httpendpoints);
-#endif
                NETIEVENT_CASE(streamdnsread);
                NETIEVENT_CASE(streamdnscancel);
 
@@ -471,10 +468,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
        isc__networker_unref(worker);
 }
 
-#ifdef HAVE_LIBNGHTTP2
-NETIEVENT_SOCKET_HTTP_EPS_DEF(httpendpoints);
-#endif /* HAVE_LIBNGHTTP2 */
-
 NETIEVENT_SOCKET_DEF(streamdnsread);
 NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel);