diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index 719b769f19..3ab5e11583 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -250,7 +250,6 @@ struct isc_nmhandle { }; typedef enum isc__netievent_type { - netievent_streamdnsread, netievent_streamdnscancel, netievent_settlsctx, @@ -1451,9 +1450,6 @@ isc__nm_http_set_max_streams(isc_nmsocket_t *listener, #endif -void -isc__nm_async_streamdnsread(isc__networker_t *worker, isc__netievent_t *ev0); - void isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg); @@ -1638,7 +1634,6 @@ isc__nmsocket_stop(isc_nmsocket_t *listener); NETIEVENT_SOCKET_REQ_RESULT_TYPE(sendcb); -NETIEVENT_SOCKET_TYPE(streamdnsread); NETIEVENT_SOCKET_HANDLE_TYPE(streamdnscancel); NETIEVENT_SOCKET_TLSCTX_TYPE(settlsctx); @@ -1648,7 +1643,6 @@ NETIEVENT_SOCKET_TYPE(sockstop); NETIEVENT_SOCKET_REQ_RESULT_DECL(sendcb); -NETIEVENT_SOCKET_DECL(streamdnsread); NETIEVENT_SOCKET_HANDLE_DECL(streamdnscancel); NETIEVENT_SOCKET_TLSCTX_DECL(settlsctx); diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index 3c9f045887..b77b83f09f 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -439,7 +439,6 @@ process_netievent(void *arg) { isc__networker_t *worker = ievent->worker; switch (ievent->type) { - NETIEVENT_CASE(streamdnsread); NETIEVENT_CASE(streamdnscancel); NETIEVENT_CASE(settlsctx); @@ -468,7 +467,6 @@ isc__nm_put_netievent(isc__networker_t *worker, void *ievent) { isc__networker_unref(worker); } -NETIEVENT_SOCKET_DEF(streamdnsread); NETIEVENT_SOCKET_HANDLE_DEF(streamdnscancel); NETIEVENT_SOCKET_TLSCTX_DEF(settlsctx); diff --git a/lib/isc/netmgr/streamdns.c b/lib/isc/netmgr/streamdns.c index 1905364ad0..9fe73ea2c8 100644 --- a/lib/isc/netmgr/streamdns.c +++ b/lib/isc/netmgr/streamdns.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -797,26 +798,26 @@ isc__nm_streamdns_cleanup_data(isc_nmsocket_t *sock) { } } -void -isc__nm_async_streamdnsread(isc__networker_t *worker, isc__netievent_t *ev0) { - isc__netievent_streamdnsread_t *ievent = - (isc__netievent_streamdnsread_t *)ev0; - isc_nmsocket_t *sock = ievent->sock; +static void +streamdns_read_cb(void *arg) { + isc_nmsocket_t *sock = arg; + REQUIRE(VALID_NMSOCK(sock)); REQUIRE(sock->tid == isc_tid()); - UNUSED(worker); if (streamdns_closing(sock)) { streamdns_failed_read_cb(sock, ISC_R_CANCELED, false); - return; + goto detach; } if (sock->streamdns.reading) { - return; + goto detach; } INSIST(VALID_NMHANDLE(sock->outerhandle)); streamdns_handle_incoming_data(sock, sock->outerhandle, NULL, 0); +detach: + isc__nmsocket_detach(&sock); } void @@ -847,9 +848,8 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, if (!closing && isc_dnsstream_assembler_result(sock->streamdns.input) == ISC_R_UNSET) { - isc__netievent_streamdnsread_t event = { .sock = sock }; - isc__nm_async_streamdnsread(sock->worker, - (isc__netievent_t *)&event); + isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL }); + streamdns_read_cb(sock); return; } @@ -863,9 +863,9 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, * 2. Due to the above, we need to make the operation * asynchronous to keep the socket state consistent. */ - isc__netievent_streamdnsread_t *ievent = - isc__nm_get_netievent_streamdnsread(sock->worker, sock); - isc__nm_enqueue_ievent(sock->worker, (isc__netievent_t *)ievent); + + isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL }); + isc_async_run(sock->worker->loop, streamdns_read_cb, sock); } void