From 496c863776c68bd08cdbeb7d8fa5935ba63b76c2 Mon Sep 17 00:00:00 2001
From: Yann Ylavic <ylavic@apache.org>
Date: Fri, 3 Sep 2021 16:52:38 +0000
Subject: [PATCH] Merge r1892814, r1892853 from trunk:

mod_proxy: Faster unix socket path parsing in the "proxy:" URL.

The actual r->filename format is "[proxy:]unix:path|url" for UDS, no need to
strstr(,"unix:") since it's at the start of the string.


mod_proxy: Follow up to r1892814.

Save some few cycles in ap_proxy_de_socketfy() too.


Submitted by: ylavic
Reviewed by: ylavic, covener, rpluem


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1892874 13f79535-47bb-0310-9956-ffa450edef68
---
 modules/proxy/mod_proxy.c            | 2 +-
 modules/proxy/proxy_util.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
 create mode 100644 changes-entries/fix_uds_filename.txt

diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
index 60634d344c7..354bb8f660f 100644
--- a/modules/proxy/mod_proxy.c
+++ b/modules/proxy/mod_proxy.c
@@ -1975,7 +1975,7 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
      * the UDS path... ignore it
      */
     if (!ap_cstr_casecmpn(url, "unix:", 5) &&
-        ((ptr = ap_strchr_c(url, '|')) != NULL)) {
+        ((ptr = ap_strchr_c(url + 5, '|')) != NULL)) {
         /* move past the 'unix:...|' UDS path info */
         const char *ret, *c;
 
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
index 3c4ea72aba7..812c32f3584 100644
--- a/modules/proxy/proxy_util.c
+++ b/modules/proxy/proxy_util.c
@@ -2281,8 +2281,8 @@ static void fix_uds_filename(request_rec *r, char **url)
     if (!r || !r->filename) return;
 
     if (!strncmp(r->filename, "proxy:", 6) &&
-            (ptr2 = ap_strcasestr(r->filename, "unix:")) &&
-            (ptr = ap_strchr(ptr2, '|'))) {
+            !ap_cstr_casecmpn(r->filename + 6, "unix:", 5) &&
+            (ptr2 = r->filename + 6 + 5, ptr = ap_strchr(ptr2, '|'))) {
         apr_uri_t urisock;
         apr_status_t rv;
         *ptr = '\0';
