From: Yann Ylavic Date: Tue, 18 Jun 2024 14:14:08 +0000 (+0000) Subject: mod_proxy: Fix DNS requests and connections closed before the configured addressTTL... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c8d57159539ce7a7e5ed3a8cac99b2346f6636e;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy: Fix DNS requests and connections closed before the configured addressTTL. BZ 69126 * modules/proxy/proxy_util.c(ap_proxy_determine_address): Fix shared expiry compare-and-swap loop. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918410 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/changes-entries/fix_proxy_determine_address.txt b/changes-entries/fix_proxy_determine_address.txt new file mode 100644 index 00000000000..9f5f33a35c1 --- /dev/null +++ b/changes-entries/fix_proxy_determine_address.txt @@ -0,0 +1,2 @@ + *) mod_proxy: Fix DNS requests and connections closed before the + configured addressTTL. BZ 69126. [Yann Ylavic] diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index e599cd6bb9e..909a2242df4 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -2954,15 +2954,16 @@ PROXY_DECLARE(apr_status_t) ap_proxy_determine_address(const char *proxy_functio */ address->expiry = apr_atomic_read32(&worker->s->address_expiry); if (address->expiry <= now) { - apr_uint32_t new_expiry = address->expiry + ttl; - while (new_expiry <= now) { - new_expiry += ttl; - } - new_expiry = apr_atomic_cas32(&worker->s->address_expiry, - new_expiry, address->expiry); - /* race lost? well the expiry should grow anyway.. */ - AP_DEBUG_ASSERT(new_expiry > now); - address->expiry = new_expiry; + apr_uint32_t prev, next = (now + ttl) - (now % ttl); + do { + prev = apr_atomic_cas32(&worker->s->address_expiry, + next, address->expiry); + if (prev == address->expiry) { + address->expiry = next; + break; + } + address->expiry = prev; + } while (prev <= now); } } else {