From: Ondřej Surý Date: Sat, 8 Aug 2026 05:24:26 +0000 (+0200) Subject: Prevent duplicate StreamDNS read jobs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e06b5ba907831f8758e2c24a83977ef6818e08c1;p=thirdparty%2Fbind9.git Prevent duplicate StreamDNS read jobs Coalesce repeated reads while an asynchronous StreamDNS job is pending. --- diff --git a/lib/isc/netmgr/streamdns.c b/lib/isc/netmgr/streamdns.c index 9dd8b0aeab6..170d5714d33 100644 --- a/lib/isc/netmgr/streamdns.c +++ b/lib/isc/netmgr/streamdns.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -888,6 +889,8 @@ streamdns_read_cb(void *arg) { REQUIRE(VALID_NMSOCK(sock)); REQUIRE(sock->tid == isc_tid()); + sock->processing = false; + if (streamdns_closing(sock)) { streamdns_failed_read_cb(sock, ISC_R_CANCELED, false); goto detach; @@ -925,6 +928,14 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, isc_nmhandle_attach(handle, &sock->recv_handle); } + /* + * Prevent scheduling the job or processing data if streamdns_read_cb + * has been already scheduled. + */ + if (sock->processing) { + return; + } + /* * In some cases there is little sense in making the operation * asynchronous as we just want to start reading from the @@ -950,6 +961,7 @@ isc__nm_streamdns_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, */ isc__nmsocket_attach(sock, &(isc_nmsocket_t *){ NULL }); + sock->processing = true; isc_job_run(sock->worker->loop, &sock->job, streamdns_read_cb, sock); }