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

bnolsen pushed a commit to branch strat_rec
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit b0ba448f8bc3026662de4ba2bbe44e0cdfe39ac2
Author: Brian Olsen <bolsen...@comcast.com>
AuthorDate: Wed May 31 20:26:01 2023 +0000

    fix or strategies abort where ParentResult rec isn't being set (not used by 
strategies)
---
 .../experimental/parent_select/parent_select.cc    | 26 +++++++++++++---------
 proxy/ParentSelection.h                            |  4 ++--
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/plugins/experimental/parent_select/parent_select.cc 
b/plugins/experimental/parent_select/parent_select.cc
index 0408ac39e8..0c7d1d08e9 100644
--- a/plugins/experimental/parent_select/parent_select.cc
+++ b/plugins/experimental/parent_select/parent_select.cc
@@ -273,29 +273,35 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, 
char *errbuff, int errbuff
 
   const char *remap_from       = argv[0];
   const char *remap_to         = argv[1];
-  const char *config_file_path = argv[2];
+  std::string config_file_path = argv[2];
   const char *strategy_name    = argv[3];
 
-  TSDebug(PLUGIN_NAME, "%s %s Loading parent selection strategy file %s for 
strategy %s", remap_from, remap_to, config_file_path,
-          strategy_name);
-  auto file_strategies = createStrategiesFromFile(config_file_path);
+  if (config_file_path[0] != '/') {
+    config_file_path.assign(TSConfigDirGet());
+    config_file_path.append("/");
+    config_file_path.append(argv[2]);
+  }
+
+  TSDebug(PLUGIN_NAME, "%s %s Loading parent selection strategy file %s for 
strategy %s", remap_from, remap_to,
+          config_file_path.c_str(), strategy_name);
+  auto file_strategies = createStrategiesFromFile(config_file_path.c_str());
   if (file_strategies.size() == 0) {
-    TSError("[%s] %s %s Failed to parse configuration file %s", PLUGIN_NAME, 
remap_from, remap_to, config_file_path);
+    TSError("[%s] %s %s Failed to parse configuration file %s", PLUGIN_NAME, 
remap_from, remap_to, config_file_path.c_str());
     return TS_ERROR;
   }
 
-  TSDebug(PLUGIN_NAME, "'%s' '%s' successfully created strategies in file %s 
num %d", remap_from, remap_to, config_file_path,
-          int(file_strategies.size()));
+  TSDebug(PLUGIN_NAME, "'%s' '%s' successfully created strategies in file %s 
num %d", remap_from, remap_to,
+          config_file_path.c_str(), int(file_strategies.size()));
 
   auto new_strategy = file_strategies.find(strategy_name);
   if (new_strategy == file_strategies.end()) {
     TSDebug(PLUGIN_NAME, "'%s' '%s' TSRemapNewInstance strategy '%s' not found 
in file '%s'", remap_from, remap_to, strategy_name,
-            config_file_path);
+            config_file_path.c_str());
     return TS_ERROR;
   }
 
   TSDebug(PLUGIN_NAME, "'%s' '%s' TSRemapNewInstance successfully loaded 
strategy '%s' from '%s'.", remap_from, remap_to,
-          strategy_name, config_file_path);
+          strategy_name, config_file_path.c_str());
 
   // created a raw pointer _to_ a shared_ptr, because ih needs a raw pointer.
   // The raw pointer in ih will be deleted in TSRemapDeleteInstance,
@@ -307,7 +313,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char 
*errbuff, int errbuff
   TSMgmtString result;
   const char *var_name = "proxy.config.url_remap.filename";
   TSMgmtStringGet(var_name, &result);
-  TSMgmtConfigFileAdd(result, config_file_path);
+  TSMgmtConfigFileAdd(result, config_file_path.c_str());
 
   return TS_SUCCESS;
 }
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 8cd613f88c..1a2a7f9d1b 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -215,11 +215,11 @@ struct ParentResult {
   bool
   is_some() const
   {
-    if (rec == nullptr) {
+    if (nullptr == rec && nullptr == hostname) {
       // If we don't have a result, we either haven't done a parent
       // lookup yet (PARENT_UNDEFINED), or the lookup didn't match
       // anything (PARENT_DIRECT).
-      ink_assert(result == PARENT_UNDEFINED || result == PARENT_DIRECT);
+      ink_assert(result == PARENT_UNDEFINED || result == PARENT_DIRECT || 
result == PARENT_FAIL);
       return false;
     }
 

Reply via email to