You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2020/06/12 19:57:54 UTC

[trafficserver] branch master updated: Fix the relative path for template_sets_dir to be install directory (#6203)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c9e5ce1  Fix the relative path for template_sets_dir to be install directory (#6203)
c9e5ce1 is described below

commit c9e5ce1dffbcb255d6baeeecb89fb4335ed033b1
Author: Susan Hinrichs <sh...@yahoo-inc.com>
AuthorDate: Fri Jun 12 14:57:44 2020 -0500

    Fix the relative path for template_sets_dir to be install directory (#6203)
    
    Co-authored-by: Susan Hinrichs <sh...@oath.com>
---
 mgmt/RecordsConfig.cc         |  2 +-
 proxy/http/HttpBodyFactory.cc | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 41d13b2..d89e6c2 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -668,7 +668,7 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.body_factory.enable_logging", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
-  {RECT_CONFIG, "proxy.config.body_factory.template_sets_dir", RECD_STRING, "body_factory", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[^[:space:]]+$", RECA_NULL}
+  {RECT_CONFIG, "proxy.config.body_factory.template_sets_dir", RECD_STRING, TS_BUILD_SYSCONFDIR "/body_factory", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[^[:space:]]+$", RECA_NULL}
   ,
   {RECT_CONFIG, "proxy.config.body_factory.response_max_size", RECD_INT, "8192", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
   ,
diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc
index 4622cda..6d2150d 100644
--- a/proxy/http/HttpBodyFactory.cc
+++ b/proxy/http/HttpBodyFactory.cc
@@ -241,6 +241,7 @@ void
 HttpBodyFactory::reconfigure()
 {
   RecInt e;
+  RecString s = nullptr;
   bool all_found;
   int rec_err;
 
@@ -276,15 +277,22 @@ HttpBodyFactory::reconfigure()
   all_found                 = all_found && (rec_err == REC_ERR_OKAY);
   Debug("body_factory", "response_suppression_mode = %d (found = %" PRId64 ")", response_suppression_mode, e);
 
-  ats_scoped_str directory_of_template_sets(RecConfigReadConfigPath("proxy.config.body_factory.template_sets_dir", "body_factory"));
+  ats_scoped_str directory_of_template_sets;
 
-  if (access(directory_of_template_sets, R_OK) < 0) {
-    Warning("Unable to access() directory '%s': %d, %s", (const char *)directory_of_template_sets, errno, strerror(errno));
-    Warning(" Please set 'proxy.config.body_factory.template_sets_dir' ");
+  rec_err   = RecGetRecordString_Xmalloc("proxy.config.body_factory.template_sets_dir", &s);
+  all_found = all_found && (rec_err == REC_ERR_OKAY);
+  if (rec_err == REC_ERR_OKAY) {
+    directory_of_template_sets = Layout::get()->relative(s);
+    if (access(directory_of_template_sets, R_OK) < 0) {
+      Warning("Unable to access() directory '%s': %d, %s", (const char *)directory_of_template_sets, errno, strerror(errno));
+      Warning(" Please set 'proxy.config.body_factory.template_sets_dir' ");
+    }
   }
 
   Debug("body_factory", "directory_of_template_sets = '%s' ", (const char *)directory_of_template_sets);
 
+  ats_free(s);
+
   if (!all_found) {
     Warning("config changed, but can't fetch all proxy.config.body_factory values");
   }