summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2024-06-18 16:14:08 +0200
committerYann Ylavic <ylavic@apache.org>2024-06-18 16:14:08 +0200
commit4c8d57159539ce7a7e5ed3a8cac99b2346f6636e (patch)
treebe15408ab7b57c9558df28fdda437507d024603c
parentFix the Japanese translation docs of the LimitRequestBody (diff)
downloadapache2-4c8d57159539ce7a7e5ed3a8cac99b2346f6636e.tar.xz
apache2-4c8d57159539ce7a7e5ed3a8cac99b2346f6636e.zip
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
-rw-r--r--changes-entries/fix_proxy_determine_address.txt2
-rw-r--r--modules/proxy/proxy_util.c19
2 files changed, 12 insertions, 9 deletions
diff --git a/changes-entries/fix_proxy_determine_address.txt b/changes-entries/fix_proxy_determine_address.txt
new file mode 100644
index 0000000000..9f5f33a35c
--- /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 e599cd6bb9..909a2242df 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 {