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

eze pushed a commit to branch revert-5798-71x_factory
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 00375330745878439e11d6c4aaf0c668e4758d39
Author: Evan Zelkowitz <[email protected]>
AuthorDate: Thu Aug 8 12:44:00 2019 -0600

    Revert "Fix broken template path caused by ba42078 (PR 1468) (Cherry pick 
396209d4d42d0349c6cfa0b882b273641e3a5b3f)"
    
    This reverts commit c297996db199056e189b71a82fd53f028116ef62.
---
 mgmt/RecordsConfig.cc         |  2 +-
 proxy/http/HttpBodyFactory.cc | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 75c4da5..30613ff 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -753,7 +753,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}
   ,
   //# 0 - never suppress generated responses
   //# 1 - always suppress generated responses
diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc
index 1db7390..39f3950 100644
--- a/proxy/http/HttpBodyFactory.cc
+++ b/proxy/http/HttpBodyFactory.cc
@@ -171,6 +171,7 @@ HttpBodyFactory::fabricate_with_old_api(const char *type, 
HttpTransact::State *c
   // handle return of instantiated template and generate the content //
   // language and content type return values                         //
   /////////////////////////////////////////////////////////////////////
+
   if (buffer) { // got an instantiated template
     if (!plain_flag) {
       snprintf(content_language_out_buf, content_language_buf_size, "%s", 
lang_ptr);
@@ -267,6 +268,7 @@ HttpBodyFactory::reconfigure()
 //#endif
 {
   RecInt e;
+  RecString s = nullptr;
   bool all_found;
   int rec_err;
 
@@ -302,14 +304,20 @@ 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);
+  Debug("body_factory", "directory_of_template_sets = '%s' (found = %s)", 
(const char *)directory_of_template_sets, s);
+  ats_free(s);
 
   if (!all_found) {
     Warning("config changed, but can't fetch all proxy.config.body_factory 
values");

Reply via email to