This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 181593ccf5 Segmentation crash caused by setting 
unavailable_server_retry_responses in parent.config  (#11009)
181593ccf5 is described below

commit 181593ccf552f9cb4e05b86801a3d68fac7ba3d0
Author: Jasmine Emanouel <[email protected]>
AuthorDate: Thu Feb 8 03:23:16 2024 +1100

    Segmentation crash caused by setting unavailable_server_retry_responses in 
parent.config  (#11009)
    
    * Always intialize retry response code variables when parent retry is 
enabled
    
    * Create parent-retry.test.py
    
    * Update parent-retry.test.py
    
    (cherry picked from commit 640c27cc957e9f7a686a1eca1f6b611be8cf4b75)
---
 proxy/ParentSelection.cc                           |  4 +-
 tests/gold_tests/parent_proxy/parent-retry.test.py | 47 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 6cdd1611f8..040f6006bd 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -775,7 +775,7 @@ ParentRecord::Init(matcher_line *line_info)
             modulePrefix, line_num);
     delete unavailable_server_retry_responses;
     unavailable_server_retry_responses = nullptr;
-  } else if (unavailable_server_retry_responses == nullptr && (parent_retry & 
PARENT_RETRY_UNAVAILABLE_SERVER)) {
+  } else if (unavailable_server_retry_responses == nullptr && parent_retry) {
     // initialize UnavailableServerResponseCodes to the default value if 
unavailable_server_retry is enabled.
     Warning("%s initializing UnavailableServerResponseCodes on line %d to 503 
default.", modulePrefix, line_num);
     unavailable_server_retry_responses = new 
UnavailableServerResponseCodes(nullptr);
@@ -787,7 +787,7 @@ ParentRecord::Init(matcher_line *line_info)
             line_num);
     delete simple_server_retry_responses;
     simple_server_retry_responses = nullptr;
-  } else if (simple_server_retry_responses == nullptr && (parent_retry & 
PARENT_RETRY_SIMPLE)) {
+  } else if (simple_server_retry_responses == nullptr && parent_retry) {
     // initialize simple server respones codes to the default value if 
simple_retry is enabled.
     Warning("%s initializing SimpleRetryResponseCodes on line %d to 404 
default.", modulePrefix, line_num);
     simple_server_retry_responses = new SimpleRetryResponseCodes(nullptr);
diff --git a/tests/gold_tests/parent_proxy/parent-retry.test.py 
b/tests/gold_tests/parent_proxy/parent-retry.test.py
new file mode 100644
index 0000000000..e782a065fb
--- /dev/null
+++ b/tests/gold_tests/parent_proxy/parent-retry.test.py
@@ -0,0 +1,47 @@
+"""
+Test parent_retry config settings
+"""
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.testName = "Test parent_retry settings"
+Test.ContinueOnFail = True
+
+
+class ParentRetryTest:
+    """
+    Test loading parent.config with parent_retry setting enabled
+    """
+    ts_parent_hostname = "localhost:8081"
+
+    def __init__(self):
+        """Initialize the test."""
+        self._configure_ts_child()
+
+    def _configure_ts_child(self):
+        self.ts_child = Test.MakeATSProcess("ts_child")
+        self.ts_child.Disk.parent_config.AddLine(
+            f'dest_domain=. method=get parent="{self.ts_parent_hostname}" 
parent_retry=unavailable_server_retry 
unavailable_server_retry_responses="502,503"'
+        )
+
+    def run(self):
+        tr = Test.AddTestRun()
+        tr.Processes.Default.StartBefore(self.ts_child)
+        tr.Processes.Default.Command = f'curl "{self.ts_child.Variables.port}" 
--verbose'
+        tr.StillRunningAfter = self.ts_child
+
+
+ParentRetryTest().run()

Reply via email to