From: Ondřej Surý Date: Thu, 23 Mar 2023 22:52:26 +0000 (+0100) Subject: Convert stopping generic socket children to to isc_async callback X-Git-Tag: v9.19.12~66^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b107c3fbcfa8760c9bc58a8f737da9b941c9d8b;p=thirdparty%2Fbind9.git Convert stopping generic socket children to to isc_async callback 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. --- diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 96cc924de2d..4d908d34887 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -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); diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index a43ed5ff42d..4e731d9bcba 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -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;