From: Artem Boldariev Date: Mon, 24 Feb 2025 16:32:23 +0000 (+0200) Subject: DoH: Limit the number of delayed IO processing requests X-Git-Tag: v9.18.35~7^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4e8089694bfb39d9c69b8c78eda712953dfea20;p=thirdparty%2Fbind9.git DoH: Limit the number of delayed IO processing requests Previously, a function for continuing IO processing on the next UV tick was introduced (http_do_bio_async()). The intention behind this function was to ensure that http_do_bio() is eventually called at least once in the future. However, the current implementation allows queueing multiple such delayed requests needlessly. There is currently no need for these excessive requests as http_do_bio() can requeue them if needed. At the same time, each such request can lead to a memory allocation, particularly in BIND 9.18. This commit ensures that the number of enqueued delayed IO processing requests never exceeds one in order to avoid potentially bombarding IO threads with the delayed requests needlessly. (cherry picked from commit 0e1b02868a63d2c4f6f0c414b20d4b999adbcc46) --- diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 3e469d4eaef..9b72756d7d0 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -190,6 +190,8 @@ struct isc_nm_http_session { size_t data_in_flight; + bool async_queued; + /* * The statistical values below are for usage on server-side * only. They are meant to detect clients that are taking too many @@ -1704,6 +1706,8 @@ http_do_bio_async_cb(void *arg) { REQUIRE(VALID_HTTP2_SESSION(session)); + session->async_queued = false; + if (session->handle != NULL && !isc__nmsocket_closing(session->handle->sock)) { @@ -1720,10 +1724,12 @@ http_do_bio_async(isc_nm_http_session_t *session) { REQUIRE(VALID_HTTP2_SESSION(session)); if (session->handle == NULL || - isc__nmsocket_closing(session->handle->sock)) + isc__nmsocket_closing(session->handle->sock) || + session->async_queued) { return; } + session->async_queued = true; isc__nm_httpsession_attach(session, &tmpsess); isc__nm_async_run( &session->handle->sock->mgr->workers[session->handle->sock->tid],