diff --git a/lib/isc/netmgr/streamdns.c b/lib/isc/netmgr/streamdns.c index 2da8a63a0a..9dd8b0aeab 100644 --- a/lib/isc/netmgr/streamdns.c +++ b/lib/isc/netmgr/streamdns.c @@ -93,6 +93,8 @@ streamdns_closing(isc_nmsocket_t *sock); static void streamdns_resume_processing(void *arg); +static void +async_streamdns_resume_processing(void *arg); static void streamdns_resumeread(isc_nmsocket_t *sock, isc_nmhandle_t *transphandle) { @@ -193,8 +195,9 @@ streamdns_on_complete_dnsmessage(isc_dnsstream_assembler_t *dnsasm, * Process more DNS messages in the next loop tick. */ streamdns_pauseread(sock, transphandle); - isc_async_run(sock->worker->loop, streamdns_resume_processing, - sock); + isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL }); + isc_async_run(sock->worker->loop, + async_streamdns_resume_processing, sock); } return false; @@ -690,6 +693,15 @@ streamdns_resume_processing(void *arg) { streamdns_handle_incoming_data(sock, sock->outerhandle, NULL, 0); } +static void +async_streamdns_resume_processing(void *arg) { + isc_nmsocket_t *sock = (isc_nmsocket_t *)arg; + + streamdns_resume_processing(sock); + + isc__nmsocket_detach(&sock); +} + static isc_result_t streamdns_accept_cb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) { isc_nmsocket_t *listensock = (isc_nmsocket_t *)cbarg;