From: Yann Ylavic Date: Wed, 19 Jun 2024 10:39:56 +0000 (+0000) Subject: mod_proxy: Follow up to r1918412: Find if one of the conn->addr[->next] is alive. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae50c48f553773d6e4367085b5b0016b31e23221;p=thirdparty%2Fapache%2Fhttpd.git mod_proxy: Follow up to r1918412: Find if one of the conn->addr[->next] is alive. ap_proxy_connect_backend() will use the first conn->addr[->next] that works, so the current address alive can be any of them. * modules/proxy/proxy_util.c(ap_proxy_determine_address): Loop for all conn->addr[->next] to determine if addr_alive. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918429 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index 1f3a191b642..3725b7b114a 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -3017,8 +3017,18 @@ PROXY_DECLARE(apr_status_t) ap_proxy_determine_address(const char *proxy_functio proxy_addrs_equal(conn->addr, address->addr)); if (conn_alive) { apr_sockaddr_t *remote_addr = NULL; + /* apr_socket_connect() in ap_proxy_connect_backend() will + * do a simple pointer copy of its given conn->addr[->next] + * so the current conn->addr is alive iif sock->remote_addr + * is one of the conn->addr[->next]. + */ apr_socket_addr_get(&remote_addr, APR_REMOTE, conn->sock); - addr_alive = (conn->addr == remote_addr); + for (addr = conn->addr; addr; addr = addr->next) { + if (addr == remote_addr) { + addr_alive = 1; + break; + } + } } else if (conn->sock && (r ? APLOGrdebug(r) : APLOGdebug(s))) { apr_sockaddr_t *local_addr = NULL;