]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Convert stopping generic socket children to to isc_async callback
authorOndřej Surý <ondrej@isc.org>
Thu, 23 Mar 2023 22:52:26 +0000 (23:52 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 24 Mar 2023 06:58:53 +0000 (07:58 +0100)
Simplify the stopping of the generic socket children by using the
isc_async API from the loopmgr instead of using the asychronous
netievent mechanism in the netmgr.

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

index 96cc924de2decab38c94d1d4af42e118dd78f36e..4d908d34887afe9f48d24e17d6b7b447d7f967ab 100644 (file)
@@ -250,7 +250,7 @@ struct isc_nmhandle {
 };
 
 typedef enum isc__netievent_type {
-       netievent_sockstop, /* for multilayer sockets */
+       netievent_nonempty,
 } isc__netievent_type;
 
 typedef union {
@@ -1508,9 +1508,6 @@ void
 isc__nm_streamdns_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
                                 bool async);
 
-void
-isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0);
-
 void
 isc__nm_incstats(isc_nmsocket_t *sock, isc__nm_statid_t id);
 /*%<
@@ -1625,14 +1622,10 @@ isc__nmsocket_stop(isc_nmsocket_t *listener);
 
 NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb);
 
-NETIEVENT_SOCKET_TYPE(sockstop);
-
 /* Now declared the helper functions */
 
 NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb);
 
-NETIEVENT_SOCKET_DECL(sockstop);
-
 void
 isc__nm_udp_failed_read_cb(isc_nmsocket_t *sock, isc_result_t result,
                           bool async);
index a43ed5ff42dfa70713f9a4c9a12aa4ccec89d701..4e731d9bcbab44f3c48c1578885d968b80da11e9 100644 (file)
@@ -436,10 +436,8 @@ isc_nm_gettimeouts(isc_nm_t *mgr, uint32_t *initial, uint32_t *idle,
 static void
 process_netievent(void *arg) {
        isc__netievent_t *ievent = (isc__netievent_t *)arg;
-       isc__networker_t *worker = ievent->worker;
 
        switch (ievent->type) {
-               NETIEVENT_CASE(sockstop);
        default:
                UNREACHABLE();
        }
@@ -464,8 +462,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) {
        isc__networker_unref(worker);
 }
 
-NETIEVENT_SOCKET_DEF(sockstop);
-
 void
 isc__nm_process_ievent(isc__networker_t *worker, isc__netievent_t *event) {
        event->worker = worker;
@@ -1862,10 +1858,16 @@ isc_nm_stoplistening(isc_nmsocket_t *sock) {
        }
 }
 
+static void
+nmsocket_stop_cb(void *arg) {
+       isc_nmsocket_t *listener = arg;
+
+       (void)atomic_fetch_sub(&listener->rchildren, 1);
+       isc_barrier_wait(&listener->stop_barrier);
+}
+
 void
 isc__nmsocket_stop(isc_nmsocket_t *listener) {
-       isc__netievent_sockstop_t ievent = { .sock = listener };
-
        REQUIRE(VALID_NMSOCK(listener));
        REQUIRE(listener->tid == isc_tid());
        REQUIRE(listener->tid == 0);
@@ -1879,12 +1881,10 @@ isc__nmsocket_stop(isc_nmsocket_t *listener) {
        for (size_t i = 1; i < listener->nchildren; i++) {
                isc__networker_t *worker =
                        &listener->worker->netmgr->workers[i];
-               isc__netievent_sockstop_t *ev =
-                       isc__nm_get_netievent_sockstop(worker, listener);
-               isc__nm_enqueue_ievent(worker, (isc__netievent_t *)ev);
+               isc_async_run(worker->loop, nmsocket_stop_cb, listener);
        }
 
-       isc__nm_async_sockstop(listener->worker, (isc__netievent_t *)&ievent);
+       nmsocket_stop_cb(listener);
        INSIST(atomic_load(&listener->rchildren) == 0);
 
        if (!atomic_compare_exchange_strong(&listener->listening,
@@ -1914,16 +1914,6 @@ isc__nmsocket_barrier_init(isc_nmsocket_t *listener) {
        listener->barriers_initialised = true;
 }
 
-void
-isc__nm_async_sockstop(isc__networker_t *worker, isc__netievent_t *ev0) {
-       isc__netievent_sockstop_t *ievent = (isc__netievent_sockstop_t *)ev0;
-       isc_nmsocket_t *listener = ievent->sock;
-       UNUSED(worker);
-
-       (void)atomic_fetch_sub(&listener->rchildren, 1);
-       isc_barrier_wait(&listener->stop_barrier);
-}
-
 static void
 isc__nm_connectcb_job(void *arg) {
        isc__nm_uvreq_t *uvreq = arg;