]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_proxy: Fix DNS requests and connections closed before the configured addressTTL...
authorYann Ylavic <ylavic@apache.org>
Tue, 18 Jun 2024 14:14:08 +0000 (14:14 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 18 Jun 2024 14:14:08 +0000 (14:14 +0000)
* 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

changes-entries/fix_proxy_determine_address.txt [new file with mode: 0644]
modules/proxy/proxy_util.c

diff --git a/changes-entries/fix_proxy_determine_address.txt b/changes-entries/fix_proxy_determine_address.txt
new file mode 100644 (file)
index 0000000..9f5f33a
--- /dev/null
@@ -0,0 +1,2 @@
+  *) mod_proxy: Fix DNS requests and connections closed before the
+     configured addressTTL.  BZ 69126.  [Yann Ylavic]
index e599cd6bb9e5aac0c9c7eb8c710c8410f99268dd..909a2242df44ad5b23eef938c1f62a8f2d18c890 100644 (file)
@@ -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 {