You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2013/12/06 05:35:35 UTC

[01/11] git commit: TS-2401: Remove unused TS_BUILD_SYSCONFIGDIR

Updated Branches:
  refs/heads/master 853722820 -> a514c64a3


TS-2401: Remove unused TS_BUILD_SYSCONFIGDIR


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bdd7af5d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bdd7af5d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bdd7af5d

Branch: refs/heads/master
Commit: bdd7af5dcfcff16ebb07d62c9bdac2de5cf8a3bf
Parents: fa100cf
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 15:13:04 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:48 2013 -0800

----------------------------------------------------------------------
 lib/ts/ink_config.h.in | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bdd7af5d/lib/ts/ink_config.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/ink_config.h.in b/lib/ts/ink_config.h.in
index ee1e029..0b69098 100644
--- a/lib/ts/ink_config.h.in
+++ b/lib/ts/ink_config.h.in
@@ -110,7 +110,6 @@
 #define TS_BUILD_BINDIR "@rel_bindir@"
 #define TS_BUILD_SBINDIR "@rel_sbindir@"
 #define TS_BUILD_SYSCONFDIR "@rel_sysconfdir@"
-#define TS_BUILD_SYSCONFIGDIR "@exp_sysconfdir@"
 #define TS_BUILD_DATADIR "@rel_datadir@"
 #define TS_BUILD_INCLUDEDIR "@rel_includedir@"
 #define TS_BUILD_LIBDIR "@rel_libdir@"


[10/11] git commit: TS-2401: Remove cache_system_config_directory

Posted by jp...@apache.org.
TS-2401: Remove cache_system_config_directory

Remove the global cache_system_config_directory array. It was only
really being used for an error message. The only real place where
it could have been use already used Layout::sysconfdir.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b6288c44
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b6288c44
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b6288c44

Branch: refs/heads/master
Commit: b6288c446f65d48f047af8b57991d41203e4f2c0
Parents: 67306a7
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 2 15:19:56 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 iocore/cache/Cache.cc            | 33 +++------------------------
 iocore/cache/CacheHosting.cc     | 42 ++++++++++++-----------------------
 iocore/cache/P_CacheHosting.h    |  5 ++---
 iocore/cache/P_CacheInternal.h   |  1 -
 iocore/cache/Store.cc            | 12 ++--------
 iocore/cluster/ClusterMachine.cc | 12 ++++------
 lib/records/I_RecCore.h          |  2 +-
 lib/records/RecCore.cc           |  6 ++++-
 8 files changed, 31 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index bf80228..39688a7 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -77,7 +77,6 @@ int cache_config_agg_write_backlog = AGG_SIZE * 2;
 int cache_config_enable_checksum = 0;
 int cache_config_alt_rewrite_max_size = 4096;
 int cache_config_read_while_writer = 0;
-char cache_system_config_directory[PATH_NAME_MAX + 1];
 int cache_config_mutex_retry_delay = 2;
 #ifdef HTTP_CACHE
 static int enable_cache_empty_http_doc = 0;
@@ -3358,26 +3357,6 @@ ink_cache_init(ModuleVersion v)
   REC_EstablishStaticConfigInt32(cache_config_mutex_retry_delay, "proxy.config.cache.mutex_retry_delay");
   Debug("cache_init", "proxy.config.cache.mutex_retry_delay = %dms", cache_config_mutex_retry_delay);
 
-  // This is just here to make sure IOCORE "standalone" works, it's usually configured in RecordsConfig.cc
-  RecRegisterConfigString(RECT_CONFIG, "proxy.config.config_dir", TS_BUILD_SYSCONFDIR, RECU_DYNAMIC, RECC_NULL, NULL);
-  REC_ReadConfigString(cache_system_config_directory, "proxy.config.config_dir", PATH_NAME_MAX);
-  if (cache_system_config_directory[0] != '/') {
-    // Not an absolute path so use system one
-    Layout::get()->relative(cache_system_config_directory, sizeof(cache_system_config_directory), cache_system_config_directory);
-  }
-  Debug("cache_init", "proxy.config.config_dir = \"%s\"", cache_system_config_directory);
-  if (access(cache_system_config_directory, R_OK) == -1) {
-    ink_strlcpy(cache_system_config_directory, Layout::get()->sysconfdir,
-                sizeof(cache_system_config_directory));
-    Debug("cache_init", "proxy.config.config_dir = \"%s\"", cache_system_config_directory);
-    if (access(cache_system_config_directory, R_OK) == -1) {
-      fprintf(stderr,"unable to access() config dir '%s': %d, %s\n",
-              cache_system_config_directory, errno, strerror(errno));
-      fprintf(stderr, "please set config path via 'proxy.config.config_dir' \n");
-      _exit(1);
-    }
-  }
-
   REC_EstablishStaticConfigInt32(cache_config_hit_evacuate_percent, "proxy.config.cache.hit_evacuate_percent");
   Debug("cache_init", "proxy.config.cache.hit_evacuate_percent = %d", cache_config_hit_evacuate_percent);
 
@@ -3423,16 +3402,10 @@ ink_cache_init(ModuleVersion v)
     printf("%s  failed\n", err);
     exit(1);
   }
-  // XXX: The read for proxy.config.cache.storage_filename is unused!
-  //
+
   if (theCacheStore.n_disks == 0) {
-    char p[PATH_NAME_MAX + 1];
-    snprintf(p, sizeof(p), "%s/", cache_system_config_directory);
-    REC_ReadConfigString(p + strlen(p), "proxy.config.cache.storage_filename", PATH_NAME_MAX - strlen(p) - 1);
-    if (p[strlen(p) - 1] == '/' || p[strlen(p) - 1] == '\\') {
-      ink_strlcat(p, "storage.config", sizeof(p));
-    }
-    Warning("no cache disks specified in %s: cache disabled\n", p);
+    xptr<char> path(RecConfigReadConfigPath("proxy.config.cache.storage_filename", "storage.config"));
+    Warning("no cache disks specified in %s: cache disabled\n", (const char *)path);
     //exit(1);
   }
 #if TS_USE_INTERIM_CACHE == 1

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cache/CacheHosting.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/CacheHosting.cc b/iocore/cache/CacheHosting.cc
index 93ba8e6..e3c07e3 100644
--- a/iocore/cache/CacheHosting.cc
+++ b/iocore/cache/CacheHosting.cc
@@ -192,7 +192,7 @@ CacheHostMatcher::NewEntry(matcher_line * line_info)
 
 CacheHostTable::CacheHostTable(Cache * c, CacheType typ)
 {
-
+  xptr<char> config_path;
 
   config_tags = &CacheHosting_tags;
   ink_assert(config_tags != NULL);
@@ -200,16 +200,12 @@ CacheHostTable::CacheHostTable(Cache * c, CacheType typ)
   type = typ;
   cache = c;
   matcher_name = "[CacheHosting]";;
-  config_file_path[0] = '\0';
-  char *config_file = NULL;
-  REC_ReadConfigStringAlloc(config_file, "proxy.config.cache.hosting_filename");
-  ink_release_assert(config_file != NULL);
-  Layout::relative_to(config_file_path, sizeof(config_file_path),
-                      cache_system_config_directory, config_file);
-  ats_free(config_file);
   hostMatch = NULL;
 
-  m_numEntries = this->BuildTable();
+  config_path = RecConfigReadConfigPath("proxy.config.cache.hosting_filename");
+  ink_release_assert(config_path);
+
+  m_numEntries = this->BuildTable(config_path);
 }
 
 CacheHostTable::~CacheHostTable()
@@ -263,7 +259,7 @@ int fstat_wrapper(int fd, struct stat *s);
 //      from it
 //
 int
-CacheHostTable::BuildTableFromString(char *file_buf)
+CacheHostTable::BuildTableFromString(const char * config_file_path, char *file_buf)
 {
   // Table build locals
   Tokenizer bufTok("\n");
@@ -417,10 +413,8 @@ CacheHostTable::BuildTableFromString(char *file_buf)
 }
 
 int
-CacheHostTable::BuildTable()
+CacheHostTable::BuildTable(const char * config_file_path)
 {
-
-  // File I/O Locals
   char *file_buf;
   int ret;
 
@@ -432,7 +426,7 @@ CacheHostTable::BuildTable()
     return 0;
   }
 
-  ret = BuildTableFromString(file_buf);
+  ret = BuildTableFromString(config_file_path, file_buf);
   ats_free(file_buf);
   return ret;
 }
@@ -631,27 +625,19 @@ CacheHostRecord::Print()
 void
 ConfigVolumes::read_config_file()
 {
-
-// File I/O Locals
+  xptr<char> config_path;
   char *file_buf;
-  char config_file_path[PATH_NAME_MAX];
-  char *config_file = NULL;
-  config_file_path[0] = '\0';
-
-  REC_ReadConfigStringAlloc(config_file, "proxy.config.cache.volume_filename");
-  ink_release_assert(config_file != NULL);
-  Layout::relative_to(config_file_path, sizeof(config_file_path),
-                      cache_system_config_directory, config_file);
-  ats_free(config_file);
 
-  file_buf = readIntoBuffer(config_file_path, "[CacheVolition]", NULL);
+  config_path = RecConfigReadConfigPath("proxy.config.cache.volume_filename");
+  ink_release_assert(config_path);
 
+  file_buf = readIntoBuffer(config_path, "[CacheVolition]", NULL);
   if (file_buf == NULL) {
-    Warning("Cannot read the config file: %s", config_file_path);
+    Warning("Cannot read the config file: %s", (const char *)config_path);
     return;
   }
 
-  BuildListFromString(config_file_path, file_buf);
+  BuildListFromString(config_path, file_buf);
   ats_free(file_buf);
   return;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cache/P_CacheHosting.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheHosting.h b/iocore/cache/P_CacheHosting.h
index cd3ca2b..dc7008a 100644
--- a/iocore/cache/P_CacheHosting.h
+++ b/iocore/cache/P_CacheHosting.h
@@ -105,8 +105,8 @@ public:
   //  object is
   CacheHostTable(Cache *c, CacheType typ);
    ~CacheHostTable();
-  int BuildTable();
-  int BuildTableFromString(char *str);
+  int BuildTable(const char * config_file_path);
+  int BuildTableFromString(const char * config_file_path, char *str);
   void Match(char *rdata, int rlen, CacheHostResult *result);
   void Print();
 
@@ -128,7 +128,6 @@ public:
 private:
   CacheHostMatcher *hostMatch;
   const matcher_tags *config_tags;
-  char config_file_path[PATH_NAME_MAX];
   const char *matcher_name;     // Used for Debug/Warning/Error messages
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cache/P_CacheInternal.h
----------------------------------------------------------------------
diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h
index 20b89b3..f9a5845 100644
--- a/iocore/cache/P_CacheInternal.h
+++ b/iocore/cache/P_CacheInternal.h
@@ -219,7 +219,6 @@ extern int cache_config_agg_write_backlog;
 extern int cache_config_enable_checksum;
 extern int cache_config_alt_rewrite_max_size;
 extern int cache_config_read_while_writer;
-extern char cache_system_config_directory[PATH_NAME_MAX + 1];
 extern int cache_clustering_enabled;
 extern int cache_config_agg_write_backlog;
 extern int cache_config_ram_cache_compress;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cache/Store.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index bd13bfd..2e79958 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -296,17 +296,9 @@ Store::read_config(int fd)
   // Get pathname if not checking file
 
   if (fd < 0) {
-    char storage_path[PATH_NAME_MAX + 1];
-    char storage_file[PATH_NAME_MAX + 1];
-    // XXX: cache_system_config_directory is initialized
-    //      inside ink_cache_init() which is called AFTER
-    //      initialize_store().
-    //
-    // ink_strlcpy(p, cache_system_config_directory, sizeof(p));
-    REC_ReadConfigString(storage_file, "proxy.config.cache.storage_filename", PATH_NAME_MAX);
-    Layout::relative_to(storage_path, PATH_NAME_MAX, Layout::get()->sysconfdir, storage_file);
-    Debug("cache_init", "Store::read_config, fd = -1, \"%s\"", storage_path);
+    xptr<char> storage_path(RecConfigReadConfigPath("proxy.config.cache.storage_filename", "storage.config"));
 
+    Debug("cache_init", "Store::read_config, fd = -1, \"%s\"", (const char *)storage_path);
     fd =::open(storage_path, O_RDONLY);
     if (fd < 0) {
       err = "error on open";

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/iocore/cluster/ClusterMachine.cc
----------------------------------------------------------------------
diff --git a/iocore/cluster/ClusterMachine.cc b/iocore/cluster/ClusterMachine.cc
index 00e99e6..408ae8a 100644
--- a/iocore/cluster/ClusterMachine.cc
+++ b/iocore/cluster/ClusterMachine.cc
@@ -29,7 +29,7 @@
 #include "ink_config.h"
 #include <unistd.h>
 #include "P_Cluster.h"
-extern char cache_system_config_directory[PATH_NAME_MAX + 1];
+#include "I_Layout.h"
 extern int num_of_cluster_threads;
 
 MachineList *machines_config = NULL;
@@ -214,13 +214,9 @@ read_MachineList(char *filename, int afd)
   int n = -1, i = 0, ln = 0;
   MachineList *l = NULL;
   ink_assert(filename || (afd != -1));
-  char p[PATH_NAME_MAX];
-  if (filename) {
-    ink_strlcpy(p, cache_system_config_directory, sizeof(p));
-    ink_strlcat(p, "/", sizeof(p));
-    ink_strlcat(p, filename, sizeof(p));
-  }
-  int fd = ((afd != -1) ? afd : open(p, O_RDONLY));
+  xptr<char> path(Layout::get()->relative_to(Layout::get()->sysconfdir, filename));
+
+  int fd = ((afd != -1) ? afd : open(path, O_RDONLY));
   if (fd >= 0) {
     while (ink_file_fd_readline(fd, sizeof(line) - 1, line) > 0) {
       ln++;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/lib/records/I_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 44b0922..8462752 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -56,7 +56,7 @@ char * RecConfigReadSnapshotDir();
 // Return a copy of a configuration file that is relative to sysconfdir. The relative path to the configuration
 // file is specified in the configuration variable named by "file_variable". If the configuration variable has no
 // value, NULL is returned. The caller MUST release the result with ats_free().
-char * RecConfigReadConfigPath(const char * file_variable);
+char * RecConfigReadConfigPath(const char * file_variable, const char * default_value = NULL);
 
 // Test whether the named configuration value is overridden by an environment variable. Return either
 // the overridden value, or the original value. Caller MUST NOT free the result.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b6288c44/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index d76cb90..6c17cc9 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -1091,7 +1091,7 @@ RecConfigReadSnapshotDir()
 // RecConfigReadConfigPath
 //-------------------------------------------------------------------------
 char *
-RecConfigReadConfigPath(const char * file_variable)
+RecConfigReadConfigPath(const char * file_variable, const char * default_value)
 {
   char buf[PATH_NAME_MAX + 1];
 
@@ -1101,6 +1101,10 @@ RecConfigReadConfigPath(const char * file_variable)
     return Layout::get()->relative_to(Layout::get()->sysconfdir, buf);
   }
 
+  if (default_value) {
+    return Layout::get()->relative_to(Layout::get()->sysconfdir, default_value);
+  }
+
   return NULL;
 }
 


Re: [07/11] git commit: TS-2401: Remove global system_runtime_dir

Posted by Igor Galić <i....@brainsware.org>.

>    // XXX: Shouldn't that be 0664?
>    //

I think you closed TS-666 prematurely. In its stead, I opened
https://issues.apache.org/jira/browse/TS-2421 for this particular issue.

i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 8716 7A9F 989B ABD5 100F  4008 F266 55D6 2998 1641


Re: [07/11] git commit: TS-2401: Remove global system_runtime_dir

Posted by James Peach <jp...@apache.org>.
On Dec 6, 2013, at 8:15 AM, Igor Galić <i....@brainsware.org> wrote:

> 
> 
> ----- Original Message -----
>> TS-2401: Remove global system_runtime_dir
>> 
>> Introduce RecConfigReadRuntimeDir() to centralize overriding
>> Layout::runtimedir with proxy.config.local_state_dir. Use this to
>> replace all the instances of system_runtime_dir.
> 
> Do I understand it correctly that we can now (or always could?)
> easily relocate a trafficserver installation, and run multiple instances
> by simply setting a different proxy.config.local_state_dir ?

This feature was always present, but inconsistently applied. It should work correctly now. You have always been able to use $TS_ROOT to relocate $PREFIX and I've used that for test suites. Soon I'll post a patch that uses it ;)

> 
> Analogous to https://httpd.apache.org/docs/current/mod/core.html#defaultruntimedir )
> 
> I'm aware that this isn't useful for most users, but it may well be
> useful to developers.

Probably useful to ops in certain deployment environments.

J

Re: [07/11] git commit: TS-2401: Remove global system_runtime_dir

Posted by Igor Galić <i....@brainsware.org>.

----- Original Message -----
> TS-2401: Remove global system_runtime_dir
> 
> Introduce RecConfigReadRuntimeDir() to centralize overriding
> Layout::runtimedir with proxy.config.local_state_dir. Use this to
> replace all the instances of system_runtime_dir.

Do I understand it correctly that we can now (or always could?)
easily relocate a trafficserver installation, and run multiple instances
by simply setting a different proxy.config.local_state_dir ?

Analogous to https://httpd.apache.org/docs/current/mod/core.html#defaultruntimedir )

I'm aware that this isn't useful for most users, but it may well be
useful to developers.

++ i
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 8716 7A9F 989B ABD5 100F  4008 F266 55D6 2998 1641


[07/11] git commit: TS-2401: Remove global system_runtime_dir

Posted by jp...@apache.org.
TS-2401: Remove global system_runtime_dir

Introduce RecConfigReadRuntimeDir() to centralize overriding
Layout::runtimedir with proxy.config.local_state_dir. Use this to
replace all the instances of system_runtime_dir.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f438ab45
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f438ab45
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f438ab45

Branch: refs/heads/master
Commit: f438ab45e6c467a6e4fbb595c0547a06e91715d3
Parents: 88f5176
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 21:24:28 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 cmd/traffic_cop/traffic_cop.cc       | 16 +++++++++-
 example/app-template/app-template.cc |  2 --
 iocore/hostdb/HostDB.cc              | 31 +++++++++++--------
 iocore/hostdb/MultiCache.cc          |  6 ++--
 lib/records/I_RecCore.h              |  4 +++
 lib/records/I_RecDefs.h              |  2 --
 lib/records/RecConfigParse.cc        |  1 +
 lib/records/RecCore.cc               | 16 ++++++++++
 mgmt/LocalManager.cc                 |  5 +++-
 mgmt/Main.cc                         |  8 ++---
 mgmt/ProcessManager.cc               |  4 ++-
 mgmt/web2/WebIntrMain.cc             |  5 ++--
 proxy/Main.cc                        | 49 +++++++++++++------------------
 proxy/StatSystem.cc                  | 20 ++++---------
 proxy/logging/LogStandalone.cc       |  1 -
 15 files changed, 97 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/cmd/traffic_cop/traffic_cop.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
index 7a258b8..564f070 100644
--- a/cmd/traffic_cop/traffic_cop.cc
+++ b/cmd/traffic_cop/traffic_cop.cc
@@ -542,6 +542,20 @@ ConfigIntFatalError:
   exit(1);
 }
 
+static const char *
+config_read_runtime_dir()
+{
+  char state_dir[PATH_NAME_MAX + 1];
+
+  state_dir[0] = '\0';
+  config_read_string("proxy.config.local_state_dir", state_dir, sizeof(state_dir), true);
+  if (strlen(state_dir) > 0) {
+    return Layout::get()->relative(state_dir);
+  } else {
+    return ats_strdup(Layout::get()->runtimedir);
+  }
+}
+
 static void
 config_reload_records()
 {
@@ -1700,7 +1714,7 @@ init_config_dir()
   cop_log_trace("Entering init_config_dir()\n");
 
   root_dir = Layout::get()->prefix;
-  runtime_dir = Layout::get()->runtimedir;
+  runtime_dir = config_read_runtime_dir();
   config_dir = Layout::get()->sysconfdir;
 
   if (chdir(root_dir) < 0) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index 5f8cb6d..af23b2b 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -53,7 +53,6 @@ int system_num_of_processors  = ink_number_of_processors();
 int system_num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
 int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
 
-char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
 
 //int system_remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
@@ -157,7 +156,6 @@ int main(int argc, char * argv[])
 
   // Get TS directories
   ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory));
-  ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, sizeof(system_runtime_dir));
 
   if (chdir(Layout::get()->prefix) < 0) {
     fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 0ffd5bc..e0fe928 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -380,6 +380,8 @@ HostDBCache::start(int flags)
   bool reconfigure = ((flags & PROCESSOR_RECONFIGURE) ? true : false);
   bool fix = ((flags & PROCESSOR_FIX) ? true : false);
 
+  storage_path[0] = '\0';
+
   // Read configuration
   // Command line overrides manager configuration.
   //
@@ -390,20 +392,22 @@ HostDBCache::start(int flags)
   REC_ReadConfigString(storage_path, "proxy.config.hostdb.storage_path", PATH_NAME_MAX);
   REC_ReadConfigInt32(storage_size, "proxy.config.hostdb.storage_size");
 
-  if (storage_path[0] != '/') {
-    Layout::relative_to(storage_path, PATH_NAME_MAX, Layout::get()->prefix, storage_path);
+  // If proxy.config.hostdb.storage_path is not set, use the local state dir. If it is set to
+  // a relative path, make it relative to the prefix.
+  if (storage_path[0] == '\0') {
+    xptr<char> rundir(RecConfigReadRuntimeDir());
+    ink_strlcpy(storage_path, rundir, sizeof(storage_path));
+  } else if (storage_path[0] != '/') {
+    Layout::relative_to(storage_path, sizeof(storage_path), Layout::get()->prefix, storage_path);
   }
 
   Debug("hostdb", "Storage path is %s", storage_path);
 
-  // XXX: Should this be W_OK?
-  if (access(storage_path, R_OK) == -1) {
-    ink_strlcpy(storage_path, system_runtime_dir, sizeof(storage_path));
-    if (access(storage_path, R_OK) == -1) {
-      Warning("Unable to access() directory '%s': %d, %s", storage_path, errno, strerror(errno));
-      Warning(" Please set 'proxy.config.hostdb.storage_path' or 'proxy.config.local_state_dir' ");
-    }
+  if (access(storage_path, W_OK | R_OK) == -1) {
+    Warning("Unable to access() directory '%s': %d, %s", storage_path, errno, strerror(errno));
+    Warning("Please set 'proxy.config.hostdb.storage_path' or 'proxy.config.local_state_dir'");
   }
+
   hostDBStore = NEW(new Store);
   hostDBSpan = NEW(new Span);
   hostDBSpan->init(storage_path, storage_size);
@@ -411,12 +415,13 @@ HostDBCache::start(int flags)
 
   Debug("hostdb", "Opening %s, size=%d", hostdb_filename, hostdb_size);
   if (open(hostDBStore, "hostdb.config", hostdb_filename, hostdb_size, reconfigure, fix, false /* slient */ ) < 0) {
+    xptr<char> rundir(RecConfigReadRuntimeDir());
+    xptr<char> config(Layout::relative_to(rundir, "hostdb.config"));
+
     Note("reconfiguring host database");
 
-    char p[PATH_NAME_MAX + 1];
-    Layout::relative_to(p, PATH_NAME_MAX, system_runtime_dir, "hostdb.config");
-    if (unlink(p) < 0)
-      Debug("hostdb", "unable to unlink %s", p);
+    if (unlink(config) < 0)
+      Debug("hostdb", "unable to unlink %s", (const char *)config);
 
     delete hostDBStore;
     hostDBStore = NEW(new Store);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/iocore/hostdb/MultiCache.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc
index bd0fdb0..b153d75 100644
--- a/iocore/hostdb/MultiCache.cc
+++ b/iocore/hostdb/MultiCache.cc
@@ -501,9 +501,10 @@ int
 MultiCacheBase::read_config(const char *config_filename, Store & s, char *fn, int *pi, int *pbuck)
 {
   int scratch;
+  xptr<char> rundir(RecConfigReadRuntimeDir());
   char p[PATH_NAME_MAX + 1], buf[256];
 
-  Layout::relative_to(p, sizeof(p), system_runtime_dir, config_filename);
+  Layout::relative_to(p, sizeof(p), rundir, config_filename);
 
   int fd =::open(p, O_RDONLY);
   if (fd < 0)
@@ -537,10 +538,11 @@ MultiCacheBase::read_config(const char *config_filename, Store & s, char *fn, in
 int
 MultiCacheBase::write_config(const char *config_filename, int nominal_size, int abuckets)
 {
+  xptr<char> rundir(RecConfigReadRuntimeDir());
   char p[PATH_NAME_MAX + 1], buf[256];
   int fd, retcode = -1;
 
-  Layout::relative_to(p, sizeof(p), system_runtime_dir, config_filename);
+  Layout::relative_to(p, sizeof(p), rundir, config_filename);
 
   // XXX: Shouldn't that be 0664?
   //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/lib/records/I_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index dda8f44..86f6595 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -45,6 +45,10 @@ typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const
 void RecConfigFileInit(void);
 int RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version);
 
+// Return a copy of the system's local state directory, taking proxy.config.local_state_dir into account. The
+// caller MUST releease the result with ats_free().
+char * RecConfigReadRuntimeDir();
+
 // Test whether the named configuration value is overridden by an environment variable. Return either
 // the overridden value, or the original value. Caller MUST NOT free the result.
 const char * RecConfigOverrideFromEnvironment(const char * name, const char * value);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/lib/records/I_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 302b3c9..928a5ac 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -175,9 +175,7 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData *
 #define REC_VAR_NAME_DELIMITOR '.'
 #define REC_VAR_NAME_WILDCARD  '*'
 
-
 // System Defaults
-extern char system_runtime_dir[PATH_NAME_MAX + 1];
 extern char system_config_directory[PATH_NAME_MAX + 1];
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/lib/records/RecConfigParse.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc
index 0ab0726..21319b4 100644
--- a/lib/records/RecConfigParse.cc
+++ b/lib/records/RecConfigParse.cc
@@ -30,6 +30,7 @@
 #include "P_RecUtils.h"
 #include "P_RecMessage.h"
 #include "P_RecCore.h"
+#include "I_Layout.h"
 
 const char     *g_rec_config_fpath = NULL;
 LLQ            *g_rec_config_contents_llq = NULL;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 0aee4bd..50485fa 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -1053,6 +1053,22 @@ REC_readString(const char *name, bool * found, bool lock)
   return _tmp;
 }
 
+//-------------------------------------------------------------------------
+// RecConfigReadRuntimeDir
+//-------------------------------------------------------------------------
+char *
+RecConfigReadRuntimeDir()
+{
+  char buf[PATH_NAME_MAX + 1];
+
+  buf[0] = '\0';
+  RecGetRecordString("proxy.config.local_state_dir", buf, PATH_NAME_MAX);
+  if (strlen(buf) > 0) {
+    return Layout::get()->relative(buf);
+  } else {
+    return ats_strdup(Layout::get()->runtimedir);
+  }
+}
 
 //-------------------------------------------------------------------------
 // REC_SignalManager (TS)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 12adb34..4572b57 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -204,6 +204,8 @@ LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
   : BaseManager(), run_proxy(proxy_on)
 {
   bool found;
+  xptr<char> rundir(RecConfigReadRuntimeDir());
+
 #ifdef MGMT_USE_SYSLOG
   syslog_facility = 0;
 #endif
@@ -221,7 +223,8 @@ LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
     mgmt_log("Bad or missing proxy.config.lm.sem_id value; using default id %d\n", MGMT_SEMID_DEFAULT);
     mgmt_sync_key = MGMT_SEMID_DEFAULT;
   }
-  ink_strlcpy(pserver_path, system_runtime_dir, sizeof(pserver_path));
+
+  ink_strlcpy(pserver_path, rundir, sizeof(pserver_path));
 
   virt_map = NULL;
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index c8e1a33..c33f564 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -78,7 +78,6 @@ static char action_tags[1024] = "";
 static bool proxy_on = true;
 
 // TODO: Check if really need those
-char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
 
 char mgmt_path[PATH_NAME_MAX + 1];
@@ -267,6 +266,7 @@ setup_coredump()
 static void
 init_dirs()
 {
+  xptr<char> rundir(RecConfigReadRuntimeDir());
   char buf[PATH_NAME_MAX + 1];
 
   REC_ReadConfigString(buf, "proxy.config.config_dir", PATH_NAME_MAX);
@@ -279,10 +279,8 @@ init_dirs()
 
   ink_strlcpy(mgmt_path, system_config_directory, sizeof(mgmt_path));
 
-  REC_ReadConfigString(buf, "proxy.config.local_state_dir", PATH_NAME_MAX);
-  Layout::get()->relative(system_runtime_dir, PATH_NAME_MAX, buf);
-  if (access(system_runtime_dir, R_OK) == -1) {
-    mgmt_elog(0, "unable to access() local state dir '%s': %d, %s\n", system_runtime_dir, errno, strerror(errno));
+  if (access(rundir, R_OK) == -1) {
+    mgmt_elog(0, "unable to access() local state dir '%s': %d, %s\n", (const char *)rundir, errno, strerror(errno));
     mgmt_elog(0, "please set 'proxy.config.local_state_dir'\n");
     _exit(1);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/mgmt/ProcessManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 6e69f96..35bbae6 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -69,7 +69,9 @@ startProcessManager(void *arg)
 ProcessManager::ProcessManager(bool rlm):
 BaseManager(), require_lm(rlm), mgmt_sync_key(0), local_manager_sockfd(0), cbtable(NULL)
 {
-  ink_strlcpy(pserver_path, Layout::get()->runtimedir, sizeof(pserver_path));
+  xptr<char> rundir(RecConfigReadRuntimeDir());
+
+  ink_strlcpy(pserver_path, rundir, sizeof(pserver_path));
   mgmt_signal_queue = create_queue();
 
   // Set temp. process/manager timeout. Will be reconfigure later.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/mgmt/web2/WebIntrMain.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebIntrMain.cc b/mgmt/web2/WebIntrMain.cc
index ff29c97..c3a6732 100644
--- a/mgmt/web2/WebIntrMain.cc
+++ b/mgmt/web2/WebIntrMain.cc
@@ -432,11 +432,12 @@ webIntr_main(void *)
   // set up socket paths;
   char api_sock_path[1024];
   char event_sock_path[1024];
+  xptr<char> rundir(RecConfigReadRuntimeDir());
 
   bzero(api_sock_path, 1024);
   bzero(event_sock_path, 1024);
-  snprintf(api_sock_path, sizeof(api_sock_path), "%s/mgmtapisocket", system_runtime_dir);
-  snprintf(event_sock_path, sizeof(event_sock_path), "%s/eventapisocket", system_runtime_dir);
+  snprintf(api_sock_path, sizeof(api_sock_path), "%s/mgmtapisocket", (const char *)rundir);
+  snprintf(event_sock_path, sizeof(event_sock_path), "%s/eventapisocket", (const char *)rundir);
 
   // INKqa12562: MgmtAPI sockets should be created with 775 permission
   mode_t oldmask = umask(S_IWOTH);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index ec75cef..2f3e19e 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -144,7 +144,6 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST;
 static char command_string[512] = "";
 int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
-char system_runtime_dir[PATH_NAME_MAX + 1];  // Layout->runtimedir
 char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
 
 static char error_tags[1024] = "";
@@ -247,24 +246,19 @@ init_system()
 static void
 check_lockfile()
 {
-  char *lockfile = NULL;
+  xptr<char> rundir(RecConfigReadRuntimeDir());
+  xptr<char> lockfile;
   pid_t holding_pid;
   int err;
 
-  if (access(Layout::get()->runtimedir, R_OK | W_OK) == -1) {
-    fprintf(stderr,"unable to access() dir'%s': %d, %s\n",
-            Layout::get()->runtimedir, errno, strerror(errno));
-    fprintf(stderr," please set correct path in env variable TS_ROOT \n");
-    _exit(1);
-  }
-  lockfile = Layout::relative_to(Layout::get()->runtimedir, SERVER_LOCK);
+  lockfile = Layout::relative_to(rundir, SERVER_LOCK);
 
   Lockfile server_lockfile(lockfile);
   err = server_lockfile.Get(&holding_pid);
 
   if (err != 1) {
     char *reason = strerror(-err);
-    fprintf(stderr, "WARNING: Can't acquire lockfile '%s'", lockfile);
+    fprintf(stderr, "WARNING: Can't acquire lockfile '%s'", (const char *)lockfile);
 
     if ((err == 0) && (holding_pid != -1)) {
       fprintf(stderr, " (Lock file held by process ID %ld)\n", (long)holding_pid);
@@ -277,16 +271,16 @@ check_lockfile()
     }
     _exit(1);
   }
-  ats_free(lockfile);
 }
 
 static void
 init_dirs(void)
 {
+  xptr<char> rundir(RecConfigReadRuntimeDir());
+
   char buf[PATH_NAME_MAX + 1];
 
   ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, PATH_NAME_MAX);
-  ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, PATH_NAME_MAX);
 
   /*
    * XXX: There is not much sense in the following code
@@ -305,15 +299,11 @@ init_dirs(void)
     }
   }
 
-  if (access(system_runtime_dir, R_OK | W_OK) == -1) {
-    REC_ReadConfigString(buf, "proxy.config.local_state_dir", PATH_NAME_MAX);
-    Layout::get()->relative(system_runtime_dir, PATH_NAME_MAX, buf);
-    if (access(system_runtime_dir, R_OK | W_OK) == -1) {
-      fprintf(stderr,"unable to access() local state dir '%s': %d, %s\n",
-              system_runtime_dir, errno, strerror(errno));
-      fprintf(stderr,"please set 'proxy.config.local_state_dir'\n");
-      _exit(1);
-    }
+  if (access(rundir, R_OK | W_OK) == -1) {
+    fprintf(stderr,"unable to access() local state dir '%s': %d, %s\n",
+            (const char *)rundir, errno, strerror(errno));
+    fprintf(stderr,"please set 'proxy.config.local_state_dir'\n");
+    _exit(1);
   }
 
 }
@@ -553,12 +543,13 @@ cmd_clear(char *cmd)
   //bool c_adb = !strcmp(cmd, "clear_authdb");
   bool c_cache = !strcmp(cmd, "clear_cache");
 
-  char p[PATH_NAME_MAX];
   if (c_all || c_hdb) {
-    Note("Clearing Configuration");
-    Layout::relative_to(p, sizeof(p), system_runtime_dir, "hostdb.config");
-    if (unlink(p) < 0)
-      Note("unable to unlink %s", p);
+    xptr<char> rundir(RecConfigReadRuntimeDir());
+    xptr<char> config(Layout::relative_to(rundir, "hostdb.config"));
+
+    Note("Clearing HostDB Configuration");
+    if (unlink(config) < 0)
+      Note("unable to unlink %s", (const char *)config);
   }
 
   if (c_all || c_cache) {
@@ -569,6 +560,7 @@ cmd_clear(char *cmd)
       return CMD_FAILED;
     }
   }
+
   if (c_hdb || c_all) {
     Note("Clearing Host Database");
     if (hostDBProcessor.cache()->start(PROCESSOR_RECONFIGURE) < 0) {
@@ -1288,8 +1280,6 @@ main(int /* argc ATS_UNUSED */, char **argv)
     fprintf(stderr, "%s\n", appVersionInfo.FullVersionInfoStr);
     _exit(0);
   }
-  // Ensure only one copy of traffic server is running
-  check_lockfile();
 
   // Set stdout/stdin to be unbuffered
   setbuf(stdout, NULL);
@@ -1321,6 +1311,9 @@ main(int /* argc ATS_UNUSED */, char **argv)
   // Local process manager
   initialize_process_manager();
 
+  // Ensure only one copy of traffic server is running
+  check_lockfile();
+
   // Set the core limit for the process
   init_core_size();
   init_system();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/proxy/StatSystem.cc
----------------------------------------------------------------------
diff --git a/proxy/StatSystem.cc b/proxy/StatSystem.cc
index bdde869..87647eb 100644
--- a/proxy/StatSystem.cc
+++ b/proxy/StatSystem.cc
@@ -474,24 +474,14 @@ initialize_all_global_stats()
 {
   int istat, i;
   char snap_file[PATH_NAME_MAX + 1];
-  char local_state_dir[PATH_NAME_MAX + 1];
+  xptr<char> rundir(RecConfigReadRuntimeDir());
 
-  // Jira TS-21
-  REC_ReadConfigString(local_state_dir, "proxy.config.local_state_dir", PATH_NAME_MAX);
-  if (local_state_dir[0] != '/') {
-    // Not an absolute path
-    Layout::get()->relative(local_state_dir, sizeof(local_state_dir), local_state_dir);
-  }
-  if (access(local_state_dir, R_OK | W_OK) == -1) {
-    ink_strlcpy(local_state_dir, system_runtime_dir, sizeof(local_state_dir));
-    if (access(local_state_dir, R_OK | W_OK) == -1) {
-      Warning("Unable to access() local state directory '%s': %d, %s", local_state_dir, errno, strerror(errno));
-      Warning(" Please set 'proxy.config.local_state_dir' to allow statistics collection");
-    }
+  if (access(rundir, R_OK | W_OK) == -1) {
+    Warning("Unable to access() local state directory '%s': %d, %s", (const char *)rundir, errno, strerror(errno));
+    Warning(" Please set 'proxy.config.local_state_dir' to allow statistics collection");
   }
   REC_ReadConfigString(snap_file, "proxy.config.stats.snap_file", PATH_NAME_MAX);
-  Layout::relative_to(snap_filename, sizeof(snap_filename),
-                      local_state_dir, snap_file);
+  Layout::relative_to(snap_filename, sizeof(snap_filename), (const char *)rundir, snap_file);
   Debug("stats", "stat snap filename %s", snap_filename);
 
   statPagesManager.register_http("stat", stat_callback);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f438ab45/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 5bf3b6f..e731851 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -57,7 +57,6 @@ int auto_clear_hostdb_flag = 0;
 char proxy_name[MAXDNAME + 1] = "unknown";
 
 char system_config_directory[PATH_NAME_MAX + 1] = "";
-char system_runtime_dir[PATH_NAME_MAX + 1] = "";
 
 char error_tags[1024] = "";
 char action_tags[1024] = "";


[06/11] git commit: TS-2401: Remove global system_log_dir

Posted by jp...@apache.org.
TS-2401: Remove global system_log_dir

In the 2 places that actually look at this, we implement the
predictable semantics of using proxy.config.log.logfile_dir (relative
to $PREFIX) if it is specified. Otherwise we use the compile-time
log directory.  In either case, we never fall back to different
directories. We either use the one specified by the operator or
fail loudly and suddenly.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/88f51768
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/88f51768
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/88f51768

Branch: refs/heads/master
Commit: 88f51768941ea440a19d8ff9ee5ef8907b72b782
Parents: bdd7af5
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 15:51:49 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 example/app-template/app-template.cc |  2 --
 lib/records/I_RecDefs.h              |  1 -
 mgmt/Main.cc                         |  9 --------
 proxy/Initialize.cc                  |  2 +-
 proxy/Main.cc                        | 13 -----------
 proxy/logging/LogConfig.cc           | 24 +++++++++-----------
 proxy/logging/LogStandalone.cc       |  1 -
 proxy/sac.cc                         |  8 -------
 proxy/shared/DiagsConfig.cc          | 37 ++++++++++++++++++-------------
 9 files changed, 32 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index fefff13..5f8cb6d 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -55,7 +55,6 @@ int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
 
 char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
-char system_log_dir[PATH_NAME_MAX + 1];
 
 //int system_remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
@@ -159,7 +158,6 @@ int main(int argc, char * argv[])
   // Get TS directories
   ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory));
   ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, sizeof(system_runtime_dir));
-  ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir));
 
   if (chdir(Layout::get()->prefix) < 0) {
     fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/lib/records/I_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 4517357..302b3c9 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -179,6 +179,5 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData *
 // System Defaults
 extern char system_runtime_dir[PATH_NAME_MAX + 1];
 extern char system_config_directory[PATH_NAME_MAX + 1];
-extern char system_log_dir[PATH_NAME_MAX + 1];
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index a48686b..c8e1a33 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -80,7 +80,6 @@ static bool proxy_on = true;
 // TODO: Check if really need those
 char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
-char system_log_dir[PATH_NAME_MAX + 1];
 
 char mgmt_path[PATH_NAME_MAX + 1];
 
@@ -287,14 +286,6 @@ init_dirs()
     mgmt_elog(0, "please set 'proxy.config.local_state_dir'\n");
     _exit(1);
   }
-
-  REC_ReadConfigString(buf, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
-  Layout::get()->relative(system_log_dir, PATH_NAME_MAX, buf);
-  if (access(system_log_dir, W_OK) == -1) {
-    mgmt_elog(0, "unable to access() log dir'%s': %d, %s\n", system_log_dir, errno, strerror(errno));
-    mgmt_elog(0, "please set 'proxy.config.log.logfile_dir'\n");
-    _exit(1);
-  }
 }
 
 static void

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/Initialize.cc
----------------------------------------------------------------------
diff --git a/proxy/Initialize.cc b/proxy/Initialize.cc
index be296b2..54026ba 100644
--- a/proxy/Initialize.cc
+++ b/proxy/Initialize.cc
@@ -276,7 +276,7 @@ init_system_diags(char *bdt, char *bat)
   char diags_logpath[PATH_NAME_MAX + 1];
 
   ink_filepath_make(diags_logpath, sizeof(diags_logpath),
-                    system_log_dir, DIAGS_LOG_FILE);
+                    Layout::get()->logdir, DIAGS_LOG_FILE);
 
   diags_log_fp = fopen(diags_logpath, "w");
   if (diags_log_fp) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 3b7e6ae..ec75cef 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -146,7 +146,6 @@ int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
 char system_runtime_dir[PATH_NAME_MAX + 1];  // Layout->runtimedir
 char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
-char system_log_dir[PATH_NAME_MAX + 1];          // Layout->logdir
 
 static char error_tags[1024] = "";
 static char action_tags[1024] = "";
@@ -288,7 +287,6 @@ init_dirs(void)
 
   ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, PATH_NAME_MAX);
   ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, PATH_NAME_MAX);
-  ink_strlcpy(system_log_dir, Layout::get()->logdir, PATH_NAME_MAX);
 
   /*
    * XXX: There is not much sense in the following code
@@ -318,17 +316,6 @@ init_dirs(void)
     }
   }
 
-  if (access(system_log_dir, W_OK) == -1) {
-    REC_ReadConfigString(buf, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
-    Layout::get()->relative(system_log_dir, PATH_NAME_MAX, buf);
-    if (access(system_log_dir, W_OK) == -1) {
-      fprintf(stderr,"unable to access() log dir'%s':%d, %s\n",
-              system_log_dir, errno, strerror(errno));
-      fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
-      _exit(1);
-    }
-  }
-
 }
 
 //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index c411336..6cb8e68 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -66,8 +66,6 @@
 
 #define PARTITION_HEADROOM_MB 	10
 
-char *ink_prepare_dir(char *logfile_dir);
-
 void
 LogConfig::setup_default_values()
 {
@@ -248,20 +246,18 @@ LogConfig::read_configuration_variables()
     // Make it relative from Layout
     logfile_dir = Layout::get()->relative(ptr);
     ats_free(ptr);
-    if (access(logfile_dir, W_OK) == -1) {
-      ats_free(logfile_dir);
-      logfile_dir = NULL;
-      if (access(system_log_dir, W_OK) == -1) {
-        // Try 'system_root_dir/var/log/trafficserver' directory
-        fprintf(stderr,"unable to access() log dir'%s': %d, %s\n",
-                system_log_dir, errno, strerror(errno));
-        fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
-        _exit(1);
-      }
-      logfile_dir = ats_strdup(system_log_dir);
-    }
+  } else {
+    ats_free(logfile_dir);
+    logfile_dir = ats_strdup(Layout::get()->logdir);
   }
 
+  if (access(logfile_dir, R_OK | W_OK | X_OK) == -1) {
+    // Try 'system_root_dir/var/log/trafficserver' directory
+    fprintf(stderr,"unable to access log directory '%s': %d, %s\n",
+            logfile_dir, errno, strerror(errno));
+    fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
+    _exit(1);
+  }
 
   //
   // for each predefined logging format, we need to know:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 17fd687..5bf3b6f 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -58,7 +58,6 @@ char proxy_name[MAXDNAME + 1] = "unknown";
 
 char system_config_directory[PATH_NAME_MAX + 1] = "";
 char system_runtime_dir[PATH_NAME_MAX + 1] = "";
-char system_log_dir[PATH_NAME_MAX + 1] = "";
 
 char error_tags[1024] = "";
 char action_tags[1024] = "";

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/sac.cc
----------------------------------------------------------------------
diff --git a/proxy/sac.cc b/proxy/sac.cc
index f094e04..e150507 100644
--- a/proxy/sac.cc
+++ b/proxy/sac.cc
@@ -89,14 +89,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
   snprintf(configDirectoryType, sizeof(configDirectoryType), "S%d", PATH_NAME_MAX - 1);
   process_args(argument_descriptions, countof(argument_descriptions), argv);
 
-  // Get log directory
-  ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir));
-  if (access(system_log_dir, R_OK) == -1) {
-    fprintf(stderr, "unable to change to log directory \"%s\" [%d '%s']\n", system_log_dir, errno, strerror(errno));
-    fprintf(stderr, " please set correct path in env variable TS_ROOT \n");
-    exit(1);
-  }
-
   // check for the version number request
   //
   if (version_flag) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/shared/DiagsConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc
index 53af04c..27ec46b 100644
--- a/proxy/shared/DiagsConfig.cc
+++ b/proxy/shared/DiagsConfig.cc
@@ -288,6 +288,8 @@ DiagsConfig::RegisterDiagConfig()
 DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
 {
   char diags_logpath[PATH_NAME_MAX + 1];
+  xptr<char> logpath;
+
   callbacks_established = false;
   diags_log_fp = (FILE *) NULL;
   diags = NULL;
@@ -303,23 +305,26 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
     config_diags_norecords();
     return;
   }
-  ////////////////////////
-  // open the diags log //
-  ////////////////////////
-
-  if (access(system_log_dir, R_OK) == -1) {
-    REC_ReadConfigString(diags_logpath, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
-    Layout::get()->relative(system_log_dir, PATH_NAME_MAX, diags_logpath);
-
-    if (access(system_log_dir, R_OK) == -1) {
-      fprintf(stderr,"unable to access() log dir'%s': %d, %s\n",
-              system_log_dir, errno, strerror(errno));
-      fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
-      _exit(1);
-    }
+
+  // Open the diagnostics log. If proxy.config.log.logfile_dir is set use that, otherwise fall
+  // back to the configured log directory.
+
+  diags_logpath[0] = '\0';
+  REC_ReadConfigString(diags_logpath, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
+  if (strlen(diags_logpath) > 0) {
+    logpath = Layout::get()->relative(diags_logpath);
+  } else {
+    logpath = ats_strdup(Layout::get()->logdir);
+  }
+
+  if (access(logpath, W_OK | R_OK) == -1) {
+    fprintf(stderr, "unable to access log directory '%s': %d, %s\n",
+            (const char *)logpath, errno, strerror(errno));
+    fprintf(stderr, "please set 'proxy.config.log.logfile_dir'\n");
+    _exit(1);
   }
-  ink_filepath_make(diags_logpath, sizeof(diags_logpath),
-                    system_log_dir, DIAGS_LOG_FILE);
+
+  ink_filepath_make(diags_logpath, sizeof(diags_logpath), logpath, DIAGS_LOG_FILE);
 
   // open write append
   // diags_log_fp = fopen(diags_logpath,"w");


[04/11] git commit: TS-2401: ProcessManager doesn't need a directory path

Posted by jp...@apache.org.
TS-2401: ProcessManager doesn't need a directory path


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/563c1e9e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/563c1e9e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/563c1e9e

Branch: refs/heads/master
Commit: 563c1e9e68153610e11bd2c1b44415c266f77060
Parents: 8537228
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 14:37:12 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:48 2013 -0800

----------------------------------------------------------------------
 mgmt/ProcessManager.cc         | 2 +-
 mgmt/ProcessManager.h          | 2 +-
 proxy/Main.cc                  | 2 +-
 proxy/logging/LogStandalone.cc | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/563c1e9e/mgmt/ProcessManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index 5490a24..6e69f96 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -66,7 +66,7 @@ startProcessManager(void *arg)
   return ret;
 }                               /* End startProcessManager */
 
-ProcessManager::ProcessManager(bool rlm, char * /* mpath ATS_UNUSED */):
+ProcessManager::ProcessManager(bool rlm):
 BaseManager(), require_lm(rlm), mgmt_sync_key(0), local_manager_sockfd(0), cbtable(NULL)
 {
   ink_strlcpy(pserver_path, Layout::get()->runtimedir, sizeof(pserver_path));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/563c1e9e/mgmt/ProcessManager.h
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.h b/mgmt/ProcessManager.h
index 419c41c..9696b6d 100644
--- a/mgmt/ProcessManager.h
+++ b/mgmt/ProcessManager.h
@@ -49,7 +49,7 @@ class ProcessManager:public BaseManager
 {
 
 public:
-  ProcessManager(bool rlm, char *mpath);
+  ProcessManager(bool rlm);
   ~ProcessManager()
   {
     close_socket(local_manager_sockfd);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/563c1e9e/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index aed6058..b5a3873 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -365,7 +365,7 @@ initialize_process_manager()
   //
   // Start up manager
   //
-  pmgmt = NEW(new ProcessManager(remote_management_flag, management_directory));
+  pmgmt = NEW(new ProcessManager(remote_management_flag));
 
   pmgmt->start();
   RecProcessInitMessage(remote_management_flag ? RECM_CLIENT : RECM_STAND_ALONE);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/563c1e9e/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 76ea32e..366dac3 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -122,7 +122,7 @@ initialize_process_manager()
 
   //
   // Start up manager
-  pmgmt = NEW(new ProcessManager(remote_management_flag, management_directory));
+  pmgmt = NEW(new ProcessManager(remote_management_flag));
 
   pmgmt->start();
 


[02/11] git commit: TS-2401: Replace system_root_dir with Layout::prefix

Posted by jp...@apache.org.
TS-2401: Replace system_root_dir with Layout::prefix


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/fa100cff
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/fa100cff
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/fa100cff

Branch: refs/heads/master
Commit: fa100cffa77b33c723ad0236876477a3c054bac1
Parents: bb26f42
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 14:50:48 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:48 2013 -0800

----------------------------------------------------------------------
 example/app-template/app-template.cc |  8 +++-----
 iocore/hostdb/HostDB.cc              |  2 +-
 lib/records/I_RecDefs.h              |  1 -
 mgmt/Main.cc                         |  9 ++++-----
 proxy/InkAPI.cc                      |  2 +-
 proxy/Main.cc                        | 10 +++++-----
 proxy/logging/LogStandalone.cc       |  1 -
 7 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index d4d63cd..fefff13 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -53,7 +53,6 @@ int system_num_of_processors  = ink_number_of_processors();
 int system_num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
 int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
 
-char system_root_dir[PATH_NAME_MAX + 1];
 char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
 char system_log_dir[PATH_NAME_MAX + 1];
@@ -158,17 +157,16 @@ int main(int argc, char * argv[])
   }
 
   // Get TS directories
-  ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir));
   ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory));
   ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, sizeof(system_runtime_dir));
   ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir));
 
-  if (system_root_dir[0] && (chdir(system_root_dir) < 0)) {
-    fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno));
+  if (chdir(Layout::get()->prefix) < 0) {
+    fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno));
     fprintf(stderr," please set correct path in env variable TS_ROOT \n");
     _exit(1);
   } else {
-    printf("[tsapp] using root directory '%s'\n",system_root_dir);
+    printf("[tsapp] using root directory '%s'\n", Layou::get()->prefix);
   }
 
   // Diags

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 0b114b4..0ffd5bc 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -391,7 +391,7 @@ HostDBCache::start(int flags)
   REC_ReadConfigInt32(storage_size, "proxy.config.hostdb.storage_size");
 
   if (storage_path[0] != '/') {
-    Layout::relative_to(storage_path, PATH_NAME_MAX, system_root_dir, storage_path);
+    Layout::relative_to(storage_path, PATH_NAME_MAX, Layout::get()->prefix, storage_path);
   }
 
   Debug("hostdb", "Storage path is %s", storage_path);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/lib/records/I_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 9a22613..4517357 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -177,7 +177,6 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData *
 
 
 // System Defaults
-extern char system_root_dir[PATH_NAME_MAX + 1];
 extern char system_runtime_dir[PATH_NAME_MAX + 1];
 extern char system_config_directory[PATH_NAME_MAX + 1];
 extern char system_log_dir[PATH_NAME_MAX + 1];

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index 59d697a..a48686b 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -78,7 +78,6 @@ static char action_tags[1024] = "";
 static bool proxy_on = true;
 
 // TODO: Check if really need those
-char system_root_dir[PATH_NAME_MAX + 1];
 char system_runtime_dir[PATH_NAME_MAX + 1];
 char system_config_directory[PATH_NAME_MAX + 1];
 char system_log_dir[PATH_NAME_MAX + 1];
@@ -301,13 +300,14 @@ init_dirs()
 static void
 chdir_root()
 {
+  const char * prefix = Layout::get()->prefix;
 
-  if (system_root_dir[0] && (chdir(system_root_dir) < 0)) {
-    mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno));
+  if (chdir(prefix) < 0) {
+    mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", prefix, errno, strerror(errno));
     mgmt_elog(0, " please set correct path in env variable TS_ROOT \n");
     exit(1);
   } else {
-    mgmt_log("[TrafficManager] using root directory '%s'\n",system_root_dir);
+    mgmt_log("[TrafficManager] using root directory '%s'\n", prefix);
   }
 }
 
@@ -370,7 +370,6 @@ main(int argc, char **argv)
 {
   // Before accessing file system initialize Layout engine
   Layout::create();
-  ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir));
   ink_strlcpy(mgmt_path, Layout::get()->sysconfdir, sizeof(mgmt_path));
 
   // change the directory to the "root" directory

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 4b533d7..1b4ce13 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -1705,7 +1705,7 @@ TShrtime()
 const char *
 TSInstallDirGet(void)
 {
-  return system_root_dir;
+  return Layout::get()->prefix;
 }
 
 const char *

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 3cdd0f4..3b7e6ae 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -144,7 +144,6 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST;
 static char command_string[512] = "";
 int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
-char system_root_dir[PATH_NAME_MAX + 1];         // Layout->prefix
 char system_runtime_dir[PATH_NAME_MAX + 1];  // Layout->runtimedir
 char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
 char system_log_dir[PATH_NAME_MAX + 1];          // Layout->logdir
@@ -1099,13 +1098,15 @@ run_RegressionTest()
 static void
 chdir_root()
 {
-  if (system_root_dir[0] && (chdir(system_root_dir) < 0)) {
+  const char * prefix = Layout::get()->prefix;
+
+  if (chdir(prefix) < 0) {
     fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n",
-            system_root_dir, errno, strerror(errno));
+            prefix, errno, strerror(errno));
     fprintf(stderr," please set correct path in env variable TS_ROOT \n");
     _exit(1);
   } else {
-    printf("[TrafficServer] using root directory '%s'\n", system_root_dir);
+    printf("[TrafficServer] using root directory '%s'\n", prefix);
   }
 }
 
@@ -1291,7 +1292,6 @@ main(int /* argc ATS_UNUSED */, char **argv)
 
   // Before accessing file system initialize Layout engine
   Layout::create();
-  ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir));
   chdir_root(); // change directory to the install root of traffic server.
 
   process_args(argument_descriptions, countof(argument_descriptions), argv);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/fa100cff/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 014baac..17fd687 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -56,7 +56,6 @@ int remote_management_flag = 0;
 int auto_clear_hostdb_flag = 0;
 char proxy_name[MAXDNAME + 1] = "unknown";
 
-char system_root_dir[PATH_NAME_MAX + 1] = "";
 char system_config_directory[PATH_NAME_MAX + 1] = "";
 char system_runtime_dir[PATH_NAME_MAX + 1] = "";
 char system_log_dir[PATH_NAME_MAX + 1] = "";


Re: [11/11] git commit: TS-2401: update CHANGES

Posted by Igor Galić <i....@brainsware.org>.

>  Changes with Apache Traffic Server 4.2.0
>  
>  
> +  *) [TS-2401] Use Layout instead of global install path directories.
> +

Kudos!


-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.galic@brainsware.org
URL: http://brainsware.org/
GPG: 8716 7A9F 989B ABD5 100F  4008 F266 55D6 2998 1641


[11/11] git commit: TS-2401: update CHANGES

Posted by jp...@apache.org.
TS-2401: update CHANGES


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a514c64a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a514c64a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a514c64a

Branch: refs/heads/master
Commit: a514c64a35bebdd29237e73c6844604b77cd9a95
Parents: ccc01b6
Author: James Peach <jp...@apache.org>
Authored: Thu Dec 5 20:33:20 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:34:10 2013 -0800

----------------------------------------------------------------------
 CHANGES | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a514c64a/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 03a04c6..309edcf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@
 Changes with Apache Traffic Server 4.2.0
 
 
+  *) [TS-2401] Use Layout instead of global install path directories.
+
   *) [TS-2420] Remove STAT_SYNC, CONF_SYNC, and REM_SYNC threads and schedule those
    continuations in ET_TASK
 


[05/11] git commit: TS-2401: Add RecConfigReadLogDir() to wrap proxy.config.log.logfile_dir access

Posted by jp...@apache.org.
TS-2401: Add RecConfigReadLogDir() to wrap proxy.config.log.logfile_dir access


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/a1162d83
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/a1162d83
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/a1162d83

Branch: refs/heads/master
Commit: a1162d8368a3f6a3401a31983ac90181f5a11782
Parents: b6288c4
Author: James Peach <jp...@apache.org>
Authored: Tue Dec 3 13:25:11 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 lib/records/I_RecCore.h     |  4 ++++
 lib/records/RecCore.cc      | 17 +++++++++++++++++
 proxy/InkAPITest.cc         |  5 ++---
 proxy/logging/LogConfig.cc  | 12 ++----------
 proxy/shared/DiagsConfig.cc |  9 +--------
 5 files changed, 26 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1162d83/lib/records/I_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 8462752..39d2e9d 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -53,6 +53,10 @@ char * RecConfigReadRuntimeDir();
 // MUST release the result with ats_free().
 char * RecConfigReadSnapshotDir();
 
+// Return a copy of the system's log directory, taking proxy.config.log.logfile_dir into account. The caller
+// MUST release the result with ats_free().
+char * RecConfigReadLogDir();
+
 // Return a copy of a configuration file that is relative to sysconfdir. The relative path to the configuration
 // file is specified in the configuration variable named by "file_variable". If the configuration variable has no
 // value, NULL is returned. The caller MUST release the result with ats_free().

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1162d83/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 6c17cc9..96cddfc 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -1071,6 +1071,23 @@ RecConfigReadRuntimeDir()
 }
 
 //-------------------------------------------------------------------------
+// RecConfigReadLogDir
+//-------------------------------------------------------------------------
+char *
+RecConfigReadLogDir()
+{
+  char buf[PATH_NAME_MAX + 1];
+
+  buf[0] = '\0';
+  RecGetRecordString("proxy.config.log.logfile_dir", buf, PATH_NAME_MAX);
+  if (strlen(buf) > 0) {
+    return Layout::get()->relative(buf);
+  } else {
+    return ats_strdup(Layout::get()->logdir);
+  }
+}
+
+//-------------------------------------------------------------------------
 // RecConfigReadSnapshotDir.
 //-------------------------------------------------------------------------
 char *

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1162d83/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 3e0ce3a..8f97a88 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -5340,10 +5340,9 @@ REGRESSION_TEST(SDK_API_TSTextLog) (RegressionTest * test, int /* atype ATS_UNUS
 
   /* Generate a random log file name, so if we run the test several times, we won't use the
      same log file name. */
-  char *tmp = REC_ConfigReadString("proxy.config.log.logfile_dir");
+  xptr<char> tmp(RecConfigReadLogDir());
   snprintf(logname, sizeof(logname), "RegressionTestLog%d.log", (int) getpid());
-  snprintf(fullpath_logname, sizeof(fullpath_logname), "%s/%s", tmp, logname);
-  // ats_free(tmp);
+  snprintf(fullpath_logname, sizeof(fullpath_logname), "%s/%s", (const char *)tmp, logname);
 
   unlink(fullpath_logname);
   retVal = TSTextLogObjectCreate(logname, TS_LOG_MODE_ADD_TIMESTAMP, &log);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1162d83/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index 5810e8f..133ea21 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -240,16 +240,8 @@ LogConfig::read_configuration_variables()
     hostname = ptr;
   }
 
-  ptr = REC_ConfigReadString("proxy.config.log.logfile_dir");
-  if (ptr != NULL) {
-    ats_free(logfile_dir);
-    // Make it relative from Layout
-    logfile_dir = Layout::get()->relative(ptr);
-    ats_free(ptr);
-  } else {
-    ats_free(logfile_dir);
-    logfile_dir = ats_strdup(Layout::get()->logdir);
-  }
+  ats_free(logfile_dir);
+  logfile_dir = RecConfigReadLogDir();
 
   if (access(logfile_dir, R_OK | W_OK | X_OK) == -1) {
     // Try 'system_root_dir/var/log/trafficserver' directory

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/a1162d83/proxy/shared/DiagsConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc
index 27ec46b..3cb6a3d 100644
--- a/proxy/shared/DiagsConfig.cc
+++ b/proxy/shared/DiagsConfig.cc
@@ -309,14 +309,7 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
   // Open the diagnostics log. If proxy.config.log.logfile_dir is set use that, otherwise fall
   // back to the configured log directory.
 
-  diags_logpath[0] = '\0';
-  REC_ReadConfigString(diags_logpath, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
-  if (strlen(diags_logpath) > 0) {
-    logpath = Layout::get()->relative(diags_logpath);
-  } else {
-    logpath = ats_strdup(Layout::get()->logdir);
-  }
-
+  logpath = RecConfigReadLogDir();
   if (access(logpath, W_OK | R_OK) == -1) {
     fprintf(stderr, "unable to access log directory '%s': %d, %s\n",
             (const char *)logpath, errno, strerror(errno));


[08/11] git commit: TS-2401: Remove system_config_directory

Posted by jp...@apache.org.
TS-2401: Remove system_config_directory

Remove all the places the global system_config_directory is used,
replacing it with Layout::get()->sysconfdir where appropriate.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/67306a71
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/67306a71
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/67306a71

Branch: refs/heads/master
Commit: 67306a71da65f135ff85c2f4d9b966122fa5590a
Parents: f438ab4
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 2 14:48:49 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 example/app-template/app-template.cc |  7 ---
 lib/records/I_RecCore.h              | 11 +++-
 lib/records/I_RecDefs.h              |  3 -
 lib/records/RecCore.cc               | 34 ++++++++++++
 mgmt/FileManager.cc                  | 92 +++++--------------------------
 mgmt/FileManager.h                   |  1 -
 mgmt/LocalManager.cc                 | 18 ++----
 mgmt/LocalManager.h                  |  4 +-
 mgmt/Main.cc                         | 18 ++----
 mgmt/Main.h                          |  1 -
 mgmt/Rollback.cc                     | 34 +++---------
 mgmt/Rollback.h                      |  1 -
 mgmt/cluster/VMap.cc                 | 13 ++---
 mgmt/web2/WebIntrMain.cc             |  4 +-
 proxy/ControlMatcher.cc              | 13 ++---
 proxy/ControlMatcher.h               |  5 +-
 proxy/ICPConfig.cc                   | 13 ++---
 proxy/IPAllow.cc                     | 13 ++---
 proxy/IPAllow.h                      |  1 -
 proxy/InkAPI.cc                      |  3 +-
 proxy/Main.cc                        | 35 +++---------
 proxy/Plugin.cc                      | 32 +----------
 proxy/Plugin.h                       |  3 +-
 proxy/Prefetch.cc                    | 15 ++---
 proxy/Update.cc                      | 10 ++--
 proxy/http/HttpBodyFactory.cc        | 27 ++++-----
 proxy/http/HttpBodyFactory.h         |  1 -
 proxy/logging/LogConfig.cc           | 30 ++++------
 proxy/logging/LogStandalone.cc       |  4 --
 proxy/sac.cc                         |  8 +--
 30 files changed, 151 insertions(+), 303 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index af23b2b..234bf77 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -53,8 +53,6 @@ int system_num_of_processors  = ink_number_of_processors();
 int system_num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
 int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
 
-char system_config_directory[PATH_NAME_MAX + 1];
-
 //int system_remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
 //Diags *diags = NULL;
@@ -154,9 +152,6 @@ int main(int argc, char * argv[])
     _exit(0);
   }
 
-  // Get TS directories
-  ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory));
-
   if (chdir(Layout::get()->prefix) < 0) {
     fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno));
     fprintf(stderr," please set correct path in env variable TS_ROOT \n");
@@ -226,8 +221,6 @@ int main(int argc, char * argv[])
   // initialize logging (after event and net processor)
   //Log::init(system_remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
 
-  //plugin_init(system_config_directory); // plugin.config
-
   // Create accept continuation
   MyAccept *a = new MyAccept;
   a->accept_port = tsapp_port;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/lib/records/I_RecCore.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 86f6595..44b0922 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -46,9 +46,18 @@ void RecConfigFileInit(void);
 int RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version);
 
 // Return a copy of the system's local state directory, taking proxy.config.local_state_dir into account. The
-// caller MUST releease the result with ats_free().
+// caller MUST release the result with ats_free().
 char * RecConfigReadRuntimeDir();
 
+// Return a copy of the system's snapshot directory, taking proxy.config.snapshot_dir into account. The caller
+// MUST release the result with ats_free().
+char * RecConfigReadSnapshotDir();
+
+// Return a copy of a configuration file that is relative to sysconfdir. The relative path to the configuration
+// file is specified in the configuration variable named by "file_variable". If the configuration variable has no
+// value, NULL is returned. The caller MUST release the result with ats_free().
+char * RecConfigReadConfigPath(const char * file_variable);
+
 // Test whether the named configuration value is overridden by an environment variable. Return either
 // the overridden value, or the original value. Caller MUST NOT free the result.
 const char * RecConfigOverrideFromEnvironment(const char * name, const char * value);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/lib/records/I_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 928a5ac..5a9c121 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -175,7 +175,4 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData *
 #define REC_VAR_NAME_DELIMITOR '.'
 #define REC_VAR_NAME_WILDCARD  '*'
 
-// System Defaults
-extern char system_config_directory[PATH_NAME_MAX + 1];
-
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/lib/records/RecCore.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 50485fa..d76cb90 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -1071,6 +1071,40 @@ RecConfigReadRuntimeDir()
 }
 
 //-------------------------------------------------------------------------
+// RecConfigReadSnapshotDir.
+//-------------------------------------------------------------------------
+char *
+RecConfigReadSnapshotDir()
+{
+  char buf[PATH_NAME_MAX + 1];
+
+  buf[0] = '\0';
+  RecGetRecordString("proxy.config.snapshot_dir", buf, PATH_NAME_MAX);
+  if (strlen(buf) > 0) {
+    return Layout::get()->relative_to(Layout::get()->sysconfdir, buf);
+  } else {
+    return Layout::get()->relative_to(Layout::get()->sysconfdir, "snapshots");
+  }
+}
+
+//-------------------------------------------------------------------------
+// RecConfigReadConfigPath
+//-------------------------------------------------------------------------
+char *
+RecConfigReadConfigPath(const char * file_variable)
+{
+  char buf[PATH_NAME_MAX + 1];
+
+  buf[0] = '\0';
+  RecGetRecordString(file_variable, buf, PATH_NAME_MAX);
+  if (strlen(buf) > 0) {
+    return Layout::get()->relative_to(Layout::get()->sysconfdir, buf);
+  }
+
+  return NULL;
+}
+
+//-------------------------------------------------------------------------
 // REC_SignalManager (TS)
 //-------------------------------------------------------------------------
 #if defined (REC_BUILD_MGMT)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/FileManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 33cafe7..8480ede 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -32,10 +32,6 @@
 #include "ExpandingArray.h"
 #include "MgmtSocket.h"
 
-
-
-static const char snapDir[] = "snapshots";
-
 #define DIR_MODE S_IRWXU
 #define FILE_MODE S_IRWXU
 
@@ -56,51 +52,24 @@ const char *SnapshotStrings[] = { "Request Successful\n",
 
 FileManager::FileManager()
 {
-  char configTmp[PATH_NAME_MAX + 1];
-  int pathLen;
-
   bindings = ink_hash_table_create(InkHashTableKeyType_String);
-
   ink_assert(bindings != NULL);
 
   ink_mutex_init(&accessLock, "File Manager Mutex");
   ink_mutex_init(&cbListLock, "File Changed Callback Mutex");
 
-  if (varStrFromName("proxy.config.config_dir", configTmp, sizeof(configTmp)) == false) {
-    mgmt_fatal(stderr, 0,
-               "[FileManager::FileManager] Unable to find configuration directory from proxy.config.config_dir\n");
-  }
-  if (configTmp[0] != '/') {
-    // Make it TS_ROOT relative
-    Layout::get()->relative(configTmp, sizeof(configTmp), configTmp);
-  }
-  if (access(configTmp, R_OK) == -1) {
-    ink_strlcpy(configTmp, system_config_directory,sizeof(configTmp));
-    if (access(configTmp, R_OK) == -1) {
-        mgmt_elog(0, "[FileManager::FileManager] unable to access() directory '%s': %d, %s\n",
-                mgmt_path, errno, strerror(errno));
-        mgmt_elog(0, "[FileManager::FileManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
-        _exit(1);
-    }
-  }
-  // Set up the path to the snap shot dir
-  pathLen = strlen(configTmp) + strlen(snapDir) + 3;
-  const size_t snapshotDir_size = pathLen + 1;
-  snapshotDir = new char[snapshotDir_size];
-  ink_filepath_make(snapshotDir, snapshotDir_size, configTmp, snapDir);
-
-  // Set up info for MultiFile
-  managedDir = snapshotDir;
-  dirDescript = "snapshot";
-
-  // Check to see if the directory already exists, if not create
-  //  it
+  xptr<char> snapshotDir(RecConfigReadSnapshotDir());
+
+  // Check to see if the directory already exists, if not create it.
   if (access(snapshotDir, F_OK) == -1) {
     if (mkdir(snapshotDir, DIR_MODE) < 0) {
       // Failed to create the snapshot directory
-      mgmt_fatal(stderr, 0, "[FileManager::FileManager] Failed to create the snapshot directory %s: %s\n", snapshotDir, strerror(errno));
+      mgmt_fatal(stderr, 0, "[FileManager::FileManager] Failed to create the snapshot directory %s: %s\n", (const char *)snapshotDir, strerror(errno));
     }
   }
+
+  this->managedDir = snapshotDir.release();
+  this->dirDescript = "snapshot";
 }
 
 // FileManager::~FileManager
@@ -117,11 +86,12 @@ FileManager::~FileManager()
   InkHashTableEntry *entry;
   InkHashTableIteratorState iterator_state;
 
-  // Let other operations finish and do not start any
-  //   new ones
+  // Let other operations finish and do not start any new ones
   ink_mutex_acquire(&accessLock);
 
-  delete[]snapshotDir;
+  ats_free(this->managedDir);
+  this->managedDir = NULL;
+  this->dirDescript = NULL;
 
   for (cb = cblist.pop(); cb != NULL; cb = cblist.pop()) {
     delete cb;
@@ -688,45 +658,13 @@ FileManager::copyFile(Rollback * rb, const char *snapPath)
 SnapResult
 FileManager::WalkSnaps(ExpandingArray * snapList)
 {
-
   MFresult r;
-  // These aren't used.
-  //char altSnapshotDir[256];
-  //InkHashTableValue snapDirLookup;
-  //fileBinding* snapBind;
-  //InkHashTableEntry *entry;
-  //InkHashTableIteratorState iterator_state;
-  //char *filePath;
-  bool found;
-  char config_dir[256];
-  char *snapshot_dir;
 
-  ink_mutex_acquire(&accessLock);
-  snapshot_dir = (char *) REC_readString("proxy.config.snapshot_dir", &found);
-  ink_assert(found);
-  //config_dir = lmgmt->record_data->readString("proxy.config.config_dir", &found);
-  //ink_assert(found);
-
-  if (varStrFromName("proxy.config.config_dir", config_dir, 256) == false) {
-    mgmt_fatal(stderr, 0,
-               "[FileManager::FileManager] Unable to find configuration directory from proxy.config.config_dir\n");
-  }
-
-  if (snapshot_dir == NULL) {
-    const size_t snapshot_dir_size = strlen("snapshots");
-    snapshot_dir = new char[snapshot_dir_size];
-    ink_assert(snapshot_dir);
-    snprintf(snapshot_dir, snapshot_dir_size, "%s", "snapshots");
-    RecSetRecordString("proxy.config.snapshot_dir", snapshot_dir);
-  }
-  //if(strncmp(snapshot_dir, config_dir, strlen(config_dir)))
-  if (snapshot_dir[0] != '/')
-    managedDir = newPathString(config_dir, snapshot_dir);
-  else
-    managedDir = snapshot_dir;
-  //else
-  //managedDir = snapshot_dir;
+  // The original code reset this->managedDir from proxy.config.snapshot_dir at this point. There doesn't appear to be
+  // any need for that, since managedDir is always set in the constructor and should not be changed.
+  ink_release_assert(this->managedDir != NULL);
 
+  ink_mutex_acquire(&accessLock);
 
   r = WalkFiles(snapList);
   //lmgmt->record_data ->setString("proxy.config.snapshot_dir", managedDir);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/FileManager.h
----------------------------------------------------------------------
diff --git a/mgmt/FileManager.h b/mgmt/FileManager.h
index 0d618b0..1824d5a 100644
--- a/mgmt/FileManager.h
+++ b/mgmt/FileManager.h
@@ -134,7 +134,6 @@ private:
     DLL<callbackListable> cblist;
   InkHashTable *bindings;
   //InkHashTable* g_snapshot_directory_ht;
-  char *snapshotDir;
   SnapResult copyFile(Rollback * rb, const char *snapPath);
   SnapResult readFile(const char *filePath, textBuffer * contents);
   void abortRestore(const char *abortTo);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 4572b57..21d05e6 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -200,7 +200,7 @@ LocalManager::processRunning()
   }
 }
 
-LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
+LocalManager::LocalManager(bool proxy_on)
   : BaseManager(), run_proxy(proxy_on)
 {
   bool found;
@@ -238,18 +238,10 @@ LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
   // Get the default IP binding values.
   RecHttpLoadIp("proxy.local.incoming_ip_to_bind", m_inbound_ip4, m_inbound_ip6);
 
-  config_path = REC_readString("proxy.config.config_dir", &found);
-  char *absolute_config_path = Layout::get()->relative(config_path);
-  ats_free(config_path);
-  if (access(absolute_config_path, R_OK) == -1) {
-    config_path = ats_strdup(system_config_directory);
-    if (access(config_path, R_OK) == -1) {
-        mgmt_elog(0, "[LocalManager::LocalManager] unable to access() directory '%s': %d, %s\n",
-                config_path, errno, strerror(errno));
-        mgmt_fatal(0, "[LocalManager::LocalManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
-    }
-  } else {
-    config_path = absolute_config_path;
+  if (access(Layout::get()->sysconfdir, R_OK) == -1) {
+    mgmt_elog(0, "[LocalManager::LocalManager] unable to access() directory '%s': %d, %s\n",
+	Layout::get()->sysconfdir, errno, strerror(errno));
+    mgmt_fatal(0, "[LocalManager::LocalManager] please set the 'TS_ROOT' environment variable\n");
   }
 
 #if TS_HAS_WCCP

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/LocalManager.h
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 8c60978..8370a02 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -50,14 +50,13 @@
 class LocalManager: public BaseManager
 {
 public:
-  LocalManager(char *mpath, bool proxy_on);
+  LocalManager(bool proxy_on);
 
   ~LocalManager()
   {
     delete alarm_keeper;
     delete virt_map;
     delete ccom;
-    ats_free(config_path);
     ats_free(bin_path);
     ats_free(absolute_proxy_binary);
     ats_free(proxy_name);
@@ -125,7 +124,6 @@ public:
   int process_server_timeout_msecs;
 
   char pserver_path[PATH_NAME_MAX];
-  char *config_path;
   char *bin_path;
   char *absolute_proxy_binary;
   char *proxy_name;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index c33f564..0219e68 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -64,6 +64,8 @@
 extern "C" int getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, struct passwd **resptr);
 #endif
 
+static void extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *fds_throttle);
+
 LocalManager *lmgmt = NULL;
 FileManager *configFiles;
 
@@ -77,9 +79,6 @@ static char debug_tags[1024] = "";
 static char action_tags[1024] = "";
 static bool proxy_on = true;
 
-// TODO: Check if really need those
-char system_config_directory[PATH_NAME_MAX + 1];
-
 char mgmt_path[PATH_NAME_MAX + 1];
 
 // By default, set the current directory as base
@@ -267,18 +266,13 @@ static void
 init_dirs()
 {
   xptr<char> rundir(RecConfigReadRuntimeDir());
-  char buf[PATH_NAME_MAX + 1];
 
-  REC_ReadConfigString(buf, "proxy.config.config_dir", PATH_NAME_MAX);
-  Layout::get()->relative(system_config_directory, PATH_NAME_MAX, buf);
-  if (access(system_config_directory, R_OK) == -1) {
-    mgmt_elog(0, "unable to access() config dir '%s': %d, %s\n", system_config_directory, errno, strerror(errno));
-    mgmt_elog(0, "please set config path via 'proxy.config.config_dir' \n");
+  if (access(Layout::get()->sysconfdir, R_OK) == -1) {
+    mgmt_elog(0, "unable to access() config dir '%s': %d, %s\n", Layout::get()->sysconfdir, errno, strerror(errno));
+    mgmt_elog(0, "please set the 'TS_ROOT' environment variable\n");
     _exit(1);
   }
 
-  ink_strlcpy(mgmt_path, system_config_directory, sizeof(mgmt_path));
-
   if (access(rundir, R_OK) == -1) {
     mgmt_elog(0, "unable to access() local state dir '%s': %d, %s\n", (const char *)rundir, errno, strerror(errno));
     mgmt_elog(0, "please set 'proxy.config.local_state_dir'\n");
@@ -562,7 +556,7 @@ main(int argc, char **argv)
   Init_Errata_Logging();
 #endif
   ts_host_res_global_init();
-  lmgmt = new LocalManager(mgmt_path, proxy_on);
+  lmgmt = new LocalManager(proxy_on);
   RecLocalInitMessage();
   lmgmt->initAlarm();
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/Main.h
----------------------------------------------------------------------
diff --git a/mgmt/Main.h b/mgmt/Main.h
index 12b9059..b401257 100644
--- a/mgmt/Main.h
+++ b/mgmt/Main.h
@@ -37,7 +37,6 @@
 void MgmtShutdown(int status);
 void fileUpdated(char *fname, bool incVersion);
 void runAsUser(char *userName);
-void extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *fds_throttle);
 void printUsage(void);
 
 extern FileManager *configFiles;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/Rollback.cc
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 0a4c961..6c219e3 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -30,6 +30,7 @@
 #include "ExpandingArray.h"
 #include "MgmtSocket.h"
 #include "ink_cap.h"
+#include "I_Layout.h"
 
 #define MAX_VERSION_DIGITS 11
 #define DEFAULT_BACKUPS 2
@@ -45,14 +46,11 @@ const char *RollbackStrings[] = { "Rollback Ok",
 Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
   : root_access_needed(root_access_needed_)
 {
-  char configTmp[PATH_NAME_MAX + 1];
   version_t highestSeen;        // the highest backup version
   ExpandingArray existVer(25, true);    // Exsisting versions
   struct stat fileInfo;
   MgmtInt numBak;
   char *alarmMsg;
-  struct stat s;
-  int err;
 
   // To Test, Read/Write access to the file
   int testFD;                   // For open test
@@ -70,20 +68,13 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
   fileName = new char[fileNameLen + 1];
   ink_strlcpy(fileName, baseFileName, fileNameLen + 1);
 
-
-  // Get the configuration directory - SHOULD BE CENTRALIZED SOMEWHERE
   // TODO: Use the runtime directory for storing mutable data
   // XXX: Sysconfdir should be imutable!!!
-  //
-  if (varStrFromName("proxy.config.config_dir", configTmp, PATH_NAME_MAX) == false) {
-    mgmt_log(stderr, "[Rollback::Rollback] Unable to find configuration directory from proxy.config.config_dir\n");
-    ink_assert(0);
-  }
 
-  if ((err = stat(system_config_directory, &s)) < 0) {
-    mgmt_elog(0, "[Rollback::Rollback] unable to stat() directory '%s': %d %d, %s\n",
-              system_config_directory, err, errno, strerror(errno));
-    mgmt_elog(0, "[Rollback::Rollback] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+  if (access(Layout::get()->sysconfdir, F_OK) < 0) {
+    mgmt_elog(0, "[Rollback::Rollback] unable to access() directory '%s': %d, %s\n",
+              Layout::get()->sysconfdir, errno, strerror(errno));
+    mgmt_elog(0, "[Rollback::Rollback] please set the 'TS_ROOT' environment variable\n");
     _exit(1);
   }
 
@@ -96,12 +87,6 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
   } else {
     numberBackups = DEFAULT_BACKUPS;
   }
-  // TODO: Use strdup/free instead C++ new
-  //
-  int configDirLen = strlen(system_config_directory) + 1;
-  configDir = new char[configDirLen];
-  ink_strlcpy(configDir, system_config_directory, configDirLen);
-
 
   ink_mutex_init(&fileAccessLock, "RollBack Mutex");
 
@@ -227,7 +212,6 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
 Rollback::~Rollback()
 {
   delete[]fileName;
-  delete[]configDir;
 }
 
 
@@ -240,11 +224,11 @@ Rollback::createPathStr(version_t version)
 {
 
   char *buffer;
-  int bufSize = strlen(configDir) + fileNameLen + MAX_VERSION_DIGITS + 1;
+  int bufSize = strlen(Layout::get()->sysconfdir) + fileNameLen + MAX_VERSION_DIGITS + 1;
 
   buffer = new char[bufSize];
 
-  ink_filepath_make(buffer, bufSize, configDir, fileName);
+  Layout::get()->relative_to(buffer, bufSize, Layout::get()->sysconfdir, fileName);
 
   if (version != ACTIVE_VERSION) {
     size_t pos = strlen(buffer);
@@ -727,11 +711,11 @@ Rollback::findVersions_ml(ExpandingArray * listNames)
   struct dirent *dirEntrySpace;
   struct dirent *entryPtr;
 
-  dir = opendir(configDir);
+  dir = opendir(Layout::get()->sysconfdir);
 
   if (dir == NULL) {
     mgmt_log(stderr, "[Rollback::findVersions] Unable to open configuration directory: %s: %s\n",
-             configDir, strerror(errno));
+             Layout::get()->sysconfdir, strerror(errno));
     return INVALID_VERSION;
   }
   // The fun of Solaris - readdir_r requires a buffer passed into it

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/Rollback.h
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.h b/mgmt/Rollback.h
index c033161..e3025a6 100644
--- a/mgmt/Rollback.h
+++ b/mgmt/Rollback.h
@@ -207,7 +207,6 @@ private:
   int statFile(version_t version, struct stat *buf);
   char *createPathStr(version_t version);
   RollBackCodes internalUpdate(textBuffer * buf, version_t newVersion, bool notifyChange = true, bool incVersion = true);
-  char *configDir;
   ink_mutex fileAccessLock;
   char *fileName;
   size_t fileNameLen;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/cluster/VMap.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/VMap.cc b/mgmt/cluster/VMap.cc
index 5539e6f..43cba20 100644
--- a/mgmt/cluster/VMap.cc
+++ b/mgmt/cluster/VMap.cc
@@ -35,6 +35,7 @@
 #include "VMap.h"
 #include "MgmtUtils.h"
 #include "P_RecLocal.h"
+#include "I_Layout.h"
 
 // for linux and freebsd
 #ifndef C_ISUID
@@ -303,19 +304,17 @@ VMap::lt_runGambit()
  * vaddr file.
  */
 void
-VMap::lt_readAListFile(char *data)
+VMap::lt_readAListFile(char * data)
 {
   int tmp_num_addrs = 0;
-  char buf[1024], fname[1024];
+  char buf[1024];
   char tmp_addr[1024], tmp_interface[1024];
   FILE *fin;
   char tmp_id[1024];
+  xptr<char> vaddr_path(Layout::get()->relative_to(Layout::get()->sysconfdir, data));
 
-  if (!data)
-    return;
-  snprintf(fname, sizeof(fname), "%s/%s", lmgmt->config_path, data);
-  if (!(fin = fopen(fname, "r"))) {
-    mgmt_log(stderr, "[VMap::lt_readAListFile] Unable to open file: %s, addr list unchanged\n", fname);
+  if (!(fin = fopen(vaddr_path, "r"))) {
+    mgmt_log(stderr, "[VMap::lt_readAListFile] Unable to open file: %s, addr list unchanged\n", (const char *)vaddr_path);
     return;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/mgmt/web2/WebIntrMain.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebIntrMain.cc b/mgmt/web2/WebIntrMain.cc
index c3a6732..57a2066 100644
--- a/mgmt/web2/WebIntrMain.cc
+++ b/mgmt/web2/WebIntrMain.cc
@@ -415,11 +415,11 @@ webIntr_main(void *)
 
     if ((err = stat(autoconfContext.docRoot, &s)) < 0) {
       ats_free(autoconfContext.docRoot);
-      autoconfContext.docRoot = ats_strdup(system_config_directory);
+      autoconfContext.docRoot = ats_strdup(Layout::get()->sysconfdir);
       if ((err = stat(autoconfContext.docRoot, &s)) < 0) {
         mgmt_elog(0, "[WebIntrMain] unable to stat() directory '%s': %d %d, %s\n",
                 autoconfContext.docRoot, err, errno, strerror(errno));
-        mgmt_elog(0, "[WebIntrMain] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+        mgmt_elog(0, "[WebIntrMain] please set the 'TS_ROOT' environment variable\n");
         mgmt_fatal(stderr, 0, "[WebIntrMain] No Client AutoConf Root\n");
       }
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/ControlMatcher.cc
----------------------------------------------------------------------
diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc
index 6680d69..7828e7e 100644
--- a/proxy/ControlMatcher.cc
+++ b/proxy/ControlMatcher.cc
@@ -694,8 +694,6 @@ template<class Data, class Result>
 ControlMatcher<Data, Result>::ControlMatcher(const char *file_var, const char *name, const matcher_tags * tags,
                                              int flags_in)
 {
-  char *config_file = NULL;
-
   flags = flags_in;
   ink_assert(flags & (ALLOW_HOST_TABLE | ALLOW_REGEX_TABLE | ALLOW_URL_TABLE | ALLOW_IP_TABLE));
 
@@ -703,16 +701,14 @@ ControlMatcher<Data, Result>::ControlMatcher(const char *file_var, const char *n
   ink_assert(config_tags != NULL);
 
   matcher_name = name;
-  config_file_var = ats_strdup(file_var);
   config_file_path[0] = '\0';
 
-  REC_ReadConfigStringAlloc(config_file, config_file_var);
-
   if (!(flags & DONT_BUILD_TABLE)) {
-    ink_release_assert(config_file != NULL);
-    ink_filepath_make(config_file_path, sizeof(config_file_path), system_config_directory, config_file);
+    xptr<char> config_path(RecConfigReadConfigPath(file_var));
+
+    ink_release_assert(config_path);
+    ink_strlcpy(config_file_path, config_path, sizeof(config_file_path));
   }
-  ats_free(config_file);
 
   reMatch = NULL;
   urlMatch = NULL;
@@ -729,7 +725,6 @@ ControlMatcher<Data, Result>::ControlMatcher(const char *file_var, const char *n
 
 template<class Data, class Result> ControlMatcher<Data, Result>::~ControlMatcher()
 {
-  ats_free(config_file_var);
 
   delete reMatch;
   delete urlMatch;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/ControlMatcher.h
----------------------------------------------------------------------
diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h
index c6f1c1b..c78db65 100644
--- a/proxy/ControlMatcher.h
+++ b/proxy/ControlMatcher.h
@@ -32,8 +32,8 @@
  *
  *     The control matcher module provides the ability to lookup arbitrary
  *  information specific to a URL and IP address.  The outside
- *  world only sees the ControlMatcher class which parses the revelvant
- *  configuration file and builds the lookups table
+ *  world only sees the ControlMatcher class which parses the relevant
+ *  configuration file and builds the lookup table
  *
  *     Four types of matched are supported: hostname, domain name, ip address
  *  and URL regex.  For these four types, three lookup tables are used.  Regex and
@@ -277,7 +277,6 @@ public:
   int BuildTableFromString(char *str);
   void Match(RequestData * rdata, Result * result);
   void Print();
-  char *config_file_var;        // temporary: until config is integerated
 
   int getEntryCount() { return m_numEntries; }
   HostMatcher<Data, Result> *getHostMatcher() { return hostMatch; }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/ICPConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/ICPConfig.cc b/proxy/ICPConfig.cc
index 3e19557..b5192d2 100644
--- a/proxy/ICPConfig.cc
+++ b/proxy/ICPConfig.cc
@@ -38,6 +38,7 @@
 #include "ICPProcessor.h"
 #include "ICPlog.h"
 #include "BaseManager.h"
+#include "I_Layout.h"
 
 //--------------------------------------------------------------------------
 //  Each ICP peer is described in "icp.config" with the
@@ -542,14 +543,10 @@ ICPConfiguration::icp_config_change_callback(void *data, void *value, int startu
   //
   // Build pathname to "icp.config" and open file
   //
-  ink_assert(filename);
-  char ConfigFilePath[PATH_NAME_MAX];
-  if (filename) {
-    ink_strlcpy(ConfigFilePath, system_config_directory, sizeof(ConfigFilePath));
-    ink_strlcat(ConfigFilePath, "/", sizeof(ConfigFilePath));
-    ink_strlcat(ConfigFilePath, filename, sizeof(ConfigFilePath));
-  }
-  int fd = open(ConfigFilePath, O_RDONLY);
+  ink_release_assert(filename != NULL);
+
+  xptr<char> config_path(Layout::get()->relative_to(Layout::get()->sysconfdir, filename));
+  int fd = open(config_path, O_RDONLY);
   if (fd < 0) {
     Warning("read icp.config, open failed");
     REC_SignalWarning(REC_SIGNAL_CONFIG_ERROR, "read icp.config, open failed");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/IPAllow.cc
----------------------------------------------------------------------
diff --git a/proxy/IPAllow.cc b/proxy/IPAllow.cc
index 2cd1d77..07c9eee 100644
--- a/proxy/IPAllow.cc
+++ b/proxy/IPAllow.cc
@@ -104,20 +104,15 @@ IpAllow::IpAllow(
   const char *config_var,
   const char *name,
   const char *action_val
-) : config_file_var(config_var),
-    module_name(name),
+) : module_name(name),
     action(action_val)
 {
+  xptr<char> config_path(RecConfigReadConfigPath(config_var));
 
-  char *config_file;
-
-  config_file_var = ats_strdup(config_var);
   config_file_path[0] = '\0';
+  ink_release_assert(config_path);
 
-  REC_ReadConfigStringAlloc(config_file, (char *) config_file_var);
-  ink_release_assert(config_file != NULL);
-  ink_filepath_make(config_file_path, sizeof(config_file_path), system_config_directory, config_file);
-  ats_free(config_file);
+  ink_strlcpy(config_file_path, config_path, sizeof(config_file_path));
 }
 
 IpAllow::~IpAllow()

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/IPAllow.h
----------------------------------------------------------------------
diff --git a/proxy/IPAllow.h b/proxy/IPAllow.h
index 76ecdf4..2c2d232 100644
--- a/proxy/IPAllow.h
+++ b/proxy/IPAllow.h
@@ -98,7 +98,6 @@ private:
 
   int BuildTable();
 
-  const char *config_file_var;
   char config_file_path[PATH_NAME_MAX];
   const char *module_name;
   const char *action;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 1b4ce13..1e8ecdf 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -1711,7 +1711,7 @@ TSInstallDirGet(void)
 const char *
 TSConfigDirGet(void)
 {
-  return system_config_directory;
+  return Layout::get()->sysconfdir;
 }
 
 const char *
@@ -1719,6 +1719,7 @@ TSTrafficServerVersionGet(void)
 {
   return traffic_server_version;
 }
+
 int TSTrafficServerVersionGetMajor() { return ts_major_version; }
 int TSTrafficServerVersionGetMinor() { return ts_minor_version; }
 int TSTrafficServerVersionGetPatch() { return ts_patch_version; }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 2f3e19e..bc7c2d5 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -144,8 +144,6 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST;
 static char command_string[512] = "";
 int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
-char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
-
 static char error_tags[1024] = "";
 static char action_tags[1024] = "";
 static int show_statistics = 0;
@@ -274,29 +272,15 @@ check_lockfile()
 }
 
 static void
-init_dirs(void)
+check_config_directories(void)
 {
   xptr<char> rundir(RecConfigReadRuntimeDir());
 
-  char buf[PATH_NAME_MAX + 1];
-
-  ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, PATH_NAME_MAX);
-
-  /*
-   * XXX: There is not much sense in the following code
-   * The purpose of proxy.config.foo_dir should
-   * be checked BEFORE checking default foo directory.
-   * Otherwise one cannot change the config dir to something else
-   */
-  if (access(system_config_directory, R_OK) == -1) {
-    REC_ReadConfigString(buf, "proxy.config.config_dir", PATH_NAME_MAX);
-    Layout::get()->relative(system_config_directory, PATH_NAME_MAX, buf);
-    if (access(system_config_directory, R_OK) == -1) {
-      fprintf(stderr,"unable to access() config dir '%s': %d, %s\n",
-              system_config_directory, errno, strerror(errno));
-      fprintf(stderr, "please set config path via 'proxy.config.config_dir' \n");
-      _exit(1);
-    }
+  if (access(Layout::get()->sysconfdir, R_OK) == -1) {
+    fprintf(stderr,"unable to access() config dir '%s': %d, %s\n",
+            Layout::get()->sysconfdir, errno, strerror(errno));
+    fprintf(stderr, "please set the 'TS_ROOT' environment variable\n");
+    _exit(1);
   }
 
   if (access(rundir, R_OK | W_OK) == -1) {
@@ -327,15 +311,14 @@ initialize_process_manager()
     LibRecordsConfigInit();
     RecordsConfigOverrideFromEnvironment();
   }
-  //
+
   // Start up manager
-  //
   pmgmt = NEW(new ProcessManager(remote_management_flag));
 
   pmgmt->start();
   RecProcessInitMessage(remote_management_flag ? RECM_CLIENT : RECM_STAND_ALONE);
   pmgmt->reconfigure();
-  init_dirs();// setup directories
+  check_config_directories();
 
   //
   // Define version info records
@@ -1531,7 +1514,7 @@ main(int /* argc ATS_UNUSED */, char **argv)
     Log::init(remote_management_flag ? 0 : Log::NO_REMOTE_MANAGEMENT);
 
     // Init plugins as soon as logging is ready.
-    plugin_init(system_config_directory);        // plugin.config
+    plugin_init();        // plugin.config
     pmgmt->registerPluginCallbacks(global_config_cbs);
 
     cacheProcessor.set_after_init_callback(&CB_After_Cache_Init);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/Plugin.cc
----------------------------------------------------------------------
diff --git a/proxy/Plugin.cc b/proxy/Plugin.cc
index 5b2b19e..10ff423 100644
--- a/proxy/Plugin.cc
+++ b/proxy/Plugin.cc
@@ -221,36 +221,8 @@ not_found:
   return NULL;
 }
 
-
-int
-plugins_exist(const char *config_dir)
-{
-  char path[PATH_NAME_MAX + 1];
-  char line[1024], *p;
-  int fd;
-  int plugin_count = 0;
-
-  ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
-  fd = open(path, O_RDONLY);
-  if (fd < 0) {
-    Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));
-    return 0;
-  }
-  while (ink_file_fd_readline(fd, sizeof(line) - 1, line) > 0) {
-    p = line;
-    // strip leading white space and test for comment or blank line
-    while (*p && ParseRules::is_wslfcr(*p))
-      ++p;
-    if ((*p == '\0') || (*p == '#'))
-      continue;
-    plugin_count++;
-  }
-  close(fd);
-  return plugin_count;
-}
-
 void
-plugin_init(const char *config_dir)
+plugin_init(void)
 {
   char path[PATH_NAME_MAX + 1];
   char line[1024], *p;
@@ -267,7 +239,7 @@ plugin_init(const char *config_dir)
     INIT_ONCE = false;
   }
 
-  ink_filepath_make(path, sizeof(path), config_dir, "plugin.config");
+  Layout::get()->relative_to(path, sizeof(path), Layout::get()->sysconfdir, "plugin.config");
   fd = open(path, O_RDONLY);
   if (fd < 0) {
     Warning("unable to open plugin config file '%s': %d, %s", path, errno, strerror(errno));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/Plugin.h
----------------------------------------------------------------------
diff --git a/proxy/Plugin.h b/proxy/Plugin.h
index 4173a05..4c1ad09 100644
--- a/proxy/Plugin.h
+++ b/proxy/Plugin.h
@@ -56,7 +56,6 @@ struct PluginRegInfo
 extern DLL<PluginRegInfo> plugin_reg_list;
 extern PluginRegInfo *plugin_reg_current;
 
-void plugin_init(const char *config_dir);
-int plugins_exist(const char *config_dir);
+void plugin_init(void);
 
 #endif /* __PLUGIN_H__ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/Prefetch.cc
----------------------------------------------------------------------
diff --git a/proxy/Prefetch.cc b/proxy/Prefetch.cc
index 69f2489..182e4c3 100644
--- a/proxy/Prefetch.cc
+++ b/proxy/Prefetch.cc
@@ -26,7 +26,6 @@
 #include "Prefetch.h"
 #include "HdrUtils.h"
 #include "HttpCompat.h"
-#include "I_Layout.h"
 #include <records/I_RecHttp.h>
 #include <ts/IpMapConf.h>
 
@@ -1906,8 +1905,7 @@ config_read_proto(PrefetchBlastData &blast, const char *str)
 int
 PrefetchConfiguration::readConfiguration()
 {
-  char *conf_file_name;
-  char conf_path[PATH_NAME_MAX + 1];
+  xptr<char> conf_path;
   int fd = -1;
 
   local_http_server_port = stuffer_port = 0;
@@ -1944,24 +1942,21 @@ PrefetchConfiguration::readConfiguration()
   //pre_parse_hook = 0;
   //embedded_url_hook = 0;
 
-  conf_file_name = TS_ConfigReadString("proxy.config.prefetch.config_file");
-
-  if (conf_file_name == NULL) {
+  conf_path = RecConfigReadConfigPath("proxy.config.prefetch.config_file");
+  if (!conf_path) {
     Warning("PrefetchProcessor: No prefetch configuration file specified. Prefetch disabled\n");
     goto Lerror;
   }
-  Layout::relative_to(conf_path, sizeof(conf_path), system_config_directory, conf_file_name);
-  ats_free(conf_file_name);
 
   fd = open(conf_path, O_RDONLY);
   if (fd < 0) {
-    Error("PrefetchProcessor: Error, could not open '%s' disabling Prefetch\n", conf_path);
+    Error("PrefetchProcessor: Error, could not open '%s' disabling Prefetch\n", (const char *)conf_path);
     goto Lerror;
   }
 
   char *temp_str;
   if ((temp_str = Load_IpMap_From_File(&ip_map, fd, "prefetch_children")) != 0) {
-    Error("PrefetchProcessor: Error in reading ip_range from %s: %.256s\n", conf_path, temp_str);
+    Error("PrefetchProcessor: Error in reading ip_range from %s: %.256s\n", (const char *)conf_path, temp_str);
     ats_free(temp_str);
     goto Lerror;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/Update.cc
----------------------------------------------------------------------
diff --git a/proxy/Update.cc b/proxy/Update.cc
index 56e2367..cabfe62 100644
--- a/proxy/Update.cc
+++ b/proxy/Update.cc
@@ -32,7 +32,7 @@
 #include "URL.h"
 #include "HdrUtils.h"
 #include <records/I_RecHttp.h>
-//#include "MixtAPIInternal.h"
+#include "I_Layout.h"
 
 RecRawStatBlock *update_rsb;
 
@@ -875,17 +875,15 @@ UpdateConfigList *
 UpdateConfigManager::BuildUpdateList()
 {
   // Build pathname to "update.config" and open file
+  xptr<char> config_path;
 
-  char ConfigFilePath[PATH_NAME_MAX];
   if (_filename) {
-    ink_strlcpy(ConfigFilePath, system_config_directory, sizeof(ConfigFilePath));
-    ink_strlcat(ConfigFilePath, "/", sizeof(ConfigFilePath));
-    ink_strlcat(ConfigFilePath, _filename, sizeof(ConfigFilePath));
+    config_path = Layout::get()->relative_to(Layout::get()->sysconfdir, _filename);
   } else {
     return (UpdateConfigList *) NULL;
   }
 
-  int fd = open(ConfigFilePath, O_RDONLY);
+  int fd = open(config_path, O_RDONLY);
   if (fd < 0) {
     Warning("read update.config, open failed");
     SignalWarning(MGMT_SIGNAL_CONFIG_ERROR, "read update.config, open failed");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/http/HttpBodyFactory.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc
index ca0e7f1..632d499 100644
--- a/proxy/http/HttpBodyFactory.cc
+++ b/proxy/http/HttpBodyFactory.cc
@@ -39,6 +39,7 @@
 #include <logging/LogAccess.h>
 #include <logging/LogAccessHttp.h>
 #include "HttpCompat.h"
+#include "I_Layout.h"
 
 //////////////////////////////////////////////////////////////////////
 // The HttpBodyFactory creates HTTP response page bodies, supported //
@@ -258,11 +259,9 @@ HttpBodyFactory::reconfigure()
 //#endif
 {
   RecInt e;
-  RecString s;
+  RecString s = NULL;
   bool all_found;
   int rec_err;
-  struct stat st;
-  int err;
 
   lock();
   sanity_check();
@@ -296,27 +295,26 @@ HttpBodyFactory::reconfigure()
   all_found = all_found && (rec_err == REC_ERR_OKAY);
   Debug("body_factory", "response_suppression_mode = %d (found = %" PRId64")", response_suppression_mode, e);
 
+  xptr<char> directory_of_template_sets;
+
   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) {
-    ats_free(directory_of_template_sets);
-    directory_of_template_sets = s;
-    if ((err = stat(directory_of_template_sets, &st)) < 0) {
-      if ((err = stat(system_config_directory, &st)) < 0) {
-        Warning("Unable to stat() directory '%s': %d %d, %s", system_config_directory, err, errno, strerror(errno));
-        Warning(" Please set 'proxy.config.body_factory.template_sets_dir' ");
-      } else {
-        ats_free(directory_of_template_sets);
-        directory_of_template_sets = ats_strdup(system_config_directory);
-      }
+    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' (found = %" PRId64")", directory_of_template_sets, e);
+  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");
   }
+
   /////////////////////////////////////////////
   // clear out previous template hash tables //
   /////////////////////////////////////////////
@@ -353,7 +351,6 @@ HttpBodyFactory::HttpBodyFactory()
   ink_mutex_init(&mutex, "HttpBodyFactory::lock");
 
   table_of_sets = NULL;
-  directory_of_template_sets = NULL;
   enable_customizations = 0;
   enable_logging = true;
   callbacks_established = false;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/http/HttpBodyFactory.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpBodyFactory.h b/proxy/http/HttpBodyFactory.h
index b13ac85..4124fcc 100644
--- a/proxy/http/HttpBodyFactory.h
+++ b/proxy/http/HttpBodyFactory.h
@@ -227,7 +227,6 @@ private:
   /////////////////////////////////////
   int enable_customizations;    // 0:no custom,1:custom,2:language-targeted
   bool enable_logging;          // the user wants body factory logging
-  char *directory_of_template_sets;     // root directory for template sets
   int response_suppression_mode;        // when to suppress responses
 
   ////////////////////

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index 6cb8e68..5810e8f 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -1624,29 +1624,25 @@ static char xml_config_buffer[] = "<LogFilter> \
 void
 LogConfig::read_xml_log_config(int from_memory)
 {
-  char config_path[PATH_NAME_MAX];
+  xptr<char> config_path;
 
-  if (from_memory) {
-    snprintf(config_path, PATH_NAME_MAX, "%s", "from_memory");
-    Debug("log", "Reading from memory %s", config_path);
-  } else {
+  if (!from_memory) {
     if (xml_config_file == NULL) {
       Note("No log config file to read");
       return;
     }
-    snprintf(config_path, PATH_NAME_MAX, "%s/%s", system_config_directory, xml_config_file);
-  }
 
+    config_path = Layout::get()->relative_to(Layout::get()->sysconfdir, xml_config_file);
+  }
 
-  Debug("log-config", "Reading log config file %s", config_path);
-  Debug("xml", "%s is an XML-based config file", config_path);
-
-  InkXmlConfigFile log_config(config_path);
+  InkXmlConfigFile log_config(config_path ? (const char *)config_path : "memory://builtin");
 
   if (!from_memory) {
+    Debug("log-config", "Reading log config file %s", (const char *)config_path);
+    Debug("xml", "%s is an XML-based config file", (const char *)config_path);
 
     if (log_config.parse() < 0) {
-      Note("Error parsing log config file %s; ensure that it is XML-based", config_path);
+      Note("Error parsing log config file %s; ensure that it is XML-based", (const char *)config_path);
       return;
     }
 
@@ -2231,18 +2227,16 @@ LogConfig::read_xml_log_config(int from_memory)
 char **
 LogConfig::read_log_hosts_file(size_t * num_hosts)
 {
-  char config_path[PATH_NAME_MAX];
+  xptr<char> config_path(Layout::get()->relative_to(Layout::get()->sysconfdir, hosts_config_file));
   char line[LOG_MAX_FORMAT_LINE];
   char **hosts = NULL;
 
-  snprintf(config_path, PATH_NAME_MAX, "%s/%s", system_config_directory, hosts_config_file);
-
-  Debug("log-config", "Reading log hosts from %s", config_path);
+  Debug("log-config", "Reading log hosts from %s", (const char *)config_path);
 
   size_t nhosts = 0;
   int fd = open(config_path, O_RDONLY);
   if (fd < 0) {
-    Warning("Traffic Server can't open %s for reading log hosts " "for splitting: %s.", config_path, strerror(errno));
+    Warning("Traffic Server can't open %s for reading log hosts " "for splitting: %s.", (const char *)config_path, strerror(errno));
   } else {
     //
     // First, count the number of hosts in the file
@@ -2261,7 +2255,7 @@ LogConfig::read_log_hosts_file(size_t * num_hosts)
     //
     if (nhosts) {
       if (lseek(fd, 0, SEEK_SET) != 0) {
-        Warning("lseek failed on file %s: %s", config_path, strerror(errno));
+        Warning("lseek failed on file %s: %s", (const char *)config_path, strerror(errno));
         nhosts = 0;
       } else {
         hosts = NEW(new char *[nhosts]);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index e731851..5d79f80 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -56,8 +56,6 @@ int remote_management_flag = 0;
 int auto_clear_hostdb_flag = 0;
 char proxy_name[MAXDNAME + 1] = "unknown";
 
-char system_config_directory[PATH_NAME_MAX + 1] = "";
-
 char error_tags[1024] = "";
 char action_tags[1024] = "";
 char command_string[512] = "";
@@ -116,8 +114,6 @@ initialize_process_manager()
 
   pmgmt->reconfigure();
 
-  REC_ReadConfigString(system_config_directory, "proxy.config.config_dir", PATH_NAME_MAX);
-
   //
   // Define version info records
   //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/67306a71/proxy/sac.cc
----------------------------------------------------------------------
diff --git a/proxy/sac.cc b/proxy/sac.cc
index e150507..a9e4a9b 100644
--- a/proxy/sac.cc
+++ b/proxy/sac.cc
@@ -46,21 +46,16 @@
 #include "DiagsConfig.h"
 #include "I_Machine.h"
 
-int auto_clear_cache_flag = 0;
-
 // sac-specific command-line flags
 //
-int version_flag = 0;
+static int version_flag = 0;
 
 // command-line argument descriptions
 //
-static char configDirectoryType[8] = "S1024";
 
 ArgumentDescription argument_descriptions[] = {
 
   {"version", 'V', "Print Version Id", "T", &version_flag, NULL, NULL},
-  {"config_dir", 'c', "Config Directory", configDirectoryType,
-   &system_config_directory, NULL, NULL},
 #ifdef DEBUG
   {"error_tags", 'T', "Colon-Separated Debug Tags", "S1023", &error_tags,
    NULL, NULL},
@@ -86,7 +81,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
   Layout::create();
   // take care of command-line arguments
   //
-  snprintf(configDirectoryType, sizeof(configDirectoryType), "S%d", PATH_NAME_MAX - 1);
   process_args(argument_descriptions, countof(argument_descriptions), argv);
 
   // check for the version number request


[03/11] git commit: TS-2401: Remove unused global management_directory

Posted by jp...@apache.org.
TS-2401: Remove unused global management_directory


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bb26f42a
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bb26f42a
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bb26f42a

Branch: refs/heads/master
Commit: bb26f42affd1983370439a0337b35dc66db80879
Parents: 563c1e9
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 14:40:07 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:48 2013 -0800

----------------------------------------------------------------------
 doc/reference/commands/traffic_server.en.rst |  2 --
 proxy/Main.cc                                | 12 ------------
 proxy/Main.h                                 |  1 -
 proxy/logging/LogStandalone.cc               | 11 -----------
 proxy/sac.cc                                 |  3 ---
 5 files changed, 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb26f42a/doc/reference/commands/traffic_server.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/commands/traffic_server.en.rst b/doc/reference/commands/traffic_server.en.rst
index 8ae9aab..442a369 100644
--- a/doc/reference/commands/traffic_server.en.rst
+++ b/doc/reference/commands/traffic_server.en.rst
@@ -52,8 +52,6 @@ Description
 
 .. option:: -M, --remote_management
 
-.. option:: -d DIR, --management_dir DIR
-
 .. option:: -C CMD, --command CMD
 
 .. option:: -k, --clear_hostdb

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb26f42a/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index b5a3873..3cdd0f4 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -144,7 +144,6 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST;
 static char command_string[512] = "";
 int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
 
-char management_directory[PATH_NAME_MAX+1];      // Layout->sysconfdir
 char system_root_dir[PATH_NAME_MAX + 1];         // Layout->prefix
 char system_runtime_dir[PATH_NAME_MAX + 1];  // Layout->runtimedir
 char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
@@ -210,7 +209,6 @@ static const ArgumentDescription argument_descriptions[] = {
 
   {"interval", 'i', "Statistics Interval", "I", &show_statistics, "PROXY_STATS_INTERVAL", NULL},
   {"remote_management", 'M', "Remote Management", "T", &remote_management_flag, "PROXY_REMOTE_MANAGEMENT", NULL},
-  {"management_dir", 'd', "Management Directory", "S255", &management_directory, "PROXY_MANAGEMENT_DIRECTORY", NULL},
   {"command", 'C', "Maintenance Command to Execute", "S511", &command_string, "PROXY_COMMAND_STRING", NULL},
   {"clear_hostdb", 'k', "Clear HostDB on Startup", "F", &auto_clear_hostdb_flag, "PROXY_CLEAR_HOSTDB", NULL},
   {"clear_cache", 'K', "Clear Cache on Startup", "F", &cacheProcessor.auto_clear_flag, "PROXY_CLEAR_CACHE", NULL},
@@ -347,15 +345,6 @@ initialize_process_manager()
     remote_management_flag = true;
   }
 
-  if (access(management_directory, R_OK) == -1) {
-    ink_strlcpy(management_directory, Layout::get()->sysconfdir, sizeof(management_directory));
-    if (access(management_directory, R_OK) == -1) {
-      fprintf(stderr,"unable to access() management path '%s': %d, %s\n", management_directory, errno, strerror(errno));
-      fprintf(stderr,"please set management path via command line '-d <management directory>'\n");
-      _exit(1);
-    }
-  }
-
   RecProcessInit(remote_management_flag ? RECM_CLIENT : RECM_STAND_ALONE, diags);
 
   if (!remote_management_flag) {
@@ -1303,7 +1292,6 @@ main(int /* argc ATS_UNUSED */, char **argv)
   // Before accessing file system initialize Layout engine
   Layout::create();
   ink_strlcpy(system_root_dir, Layout::get()->prefix, sizeof(system_root_dir));
-  ink_strlcpy(management_directory, Layout::get()->sysconfdir, sizeof(management_directory));
   chdir_root(); // change directory to the install root of traffic server.
 
   process_args(argument_descriptions, countof(argument_descriptions), argv);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb26f42a/proxy/Main.h
----------------------------------------------------------------------
diff --git a/proxy/Main.h b/proxy/Main.h
index d7a9a12..363fffc 100644
--- a/proxy/Main.h
+++ b/proxy/Main.h
@@ -55,7 +55,6 @@ extern char cluster_host[MAXDNAME + 1];
 extern int cluster_port_number;
 
 extern int remote_management_flag;
-extern char management_directory[PATH_NAME_MAX + 1];
 
 inkcoreapi extern int qt_accept_file_descriptor;
 inkcoreapi extern int cache_clustering_enabled;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb26f42a/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 366dac3..014baac 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -60,7 +60,6 @@ char system_root_dir[PATH_NAME_MAX + 1] = "";
 char system_config_directory[PATH_NAME_MAX + 1] = "";
 char system_runtime_dir[PATH_NAME_MAX + 1] = "";
 char system_log_dir[PATH_NAME_MAX + 1] = "";
-char management_directory[PATH_NAME_MAX + 1] = "";
 
 char error_tags[1024] = "";
 char action_tags[1024] = "";
@@ -100,16 +99,6 @@ initialize_process_manager()
     remote_management_flag = true;
   }
 
-  if (management_directory[0] == '\0') {
-    ink_strlcpy(management_directory, Layout::get()->sysconfdir, sizeof(management_directory));
-    if (access(management_directory, R_OK) == -1) {
-      fprintf(stderr,"unable to access() management path '%s': %d, %s\n",
-              management_directory, errno, strerror(errno));
-      fprintf(stderr,"please set management path via command line '-d <management directory>'\n");
-      _exit(1);
-    }
-  }
-
   // diags should have been initialized by caller, e.g.: sac.cc
   ink_assert(diags);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb26f42a/proxy/sac.cc
----------------------------------------------------------------------
diff --git a/proxy/sac.cc b/proxy/sac.cc
index db9571e..f094e04 100644
--- a/proxy/sac.cc
+++ b/proxy/sac.cc
@@ -97,9 +97,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
     exit(1);
   }
 
-  management_directory[0] = 0;
-  ink_strlcat(management_directory, system_config_directory, sizeof(management_directory));
-
   // check for the version number request
   //
   if (version_flag) {


[09/11] git commit: TS-2401: update records.config layout documentation

Posted by jp...@apache.org.
TS-2401: update records.config layout documentation


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ccc01b66
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ccc01b66
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ccc01b66

Branch: refs/heads/master
Commit: ccc01b66370d4f617b8685b6ba755188344cc215
Parents: a1162d8
Author: James Peach <jp...@apache.org>
Authored: Thu Dec 5 20:29:52 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800

----------------------------------------------------------------------
 .../configuration/records.config.en.rst         | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ccc01b66/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index 000ed19..bbe1a4d 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -166,9 +166,13 @@ System Variables
    The script executed before the :program:`traffic_manager` process spawns
    the :program:`traffic_server` process.
 
-.. ts:cv:: CONFIG proxy.config.config_dir STRING config
+.. ts:cv:: CONFIG proxy.config.config_dir STRING etc/trafficserver
 
    The directory that contains Traffic Server configuration files.
+   This is a read-only configuration option that contains the
+   ``SYSCONFDIR`` value specified at build time relative to the
+   installation prefic. THe ``$TS_ROOT`` environment variable can
+   be used alter the installation prefix at run time.
 
 .. ts:cv:: CONFIG proxy.config.alarm_email STRING
    :reloadable:
@@ -200,8 +204,10 @@ A value of ``0`` means no signal will be sent.
 
 .. ts:cv:: CONFIG proxy.config.snapshot_dir STRING snapshots
 
-   The directory in which Traffic Server stores configuration snapshots on the local system. Unless you specify an absolute path, this
-   directory is located in the Traffic Server ``config`` directory.
+   The directory in which Traffic Server stores configuration
+   snapshots on the local system. Unless you specify an absolute
+   path, this directory is located in the Traffic Server ``SYSCONFDIR``
+   directory.
 
 .. ts:cv:: CONFIG proxy.config.exec_thread.autoconfig INT 1
 
@@ -1293,9 +1299,11 @@ Customizable User Response Pages
    Enables (``1``) or disables (``0``) logging for customizable response pages. When enabled, Traffic Server records a message in
    the error log each time a customized response page is used or modified.
 
-.. ts:cv:: CONFIG proxy.config.body_factory.template_sets_dir STRING config/body_factory
+.. ts:cv:: CONFIG proxy.config.body_factory.template_sets_dir STRING etc/trafficserver/body_factory
 
-   The customizable response page default directory.
+   The customizable response page default directory. If this is a
+   relative path, Traffic Server resolves it relative to the
+   ``PREFIX`` directory.
 
 .. ts:cv:: CONFIG proxy.config.body_factory.response_suppression_mode INT 0
 
@@ -1556,10 +1564,12 @@ Logging Configuration
 
    The hostname of the machine running Traffic Server.
 
-.. ts:cv:: CONFIG proxy.config.log.logfile_dir STRING install_dir\ ``/logs``
+.. ts:cv:: CONFIG proxy.config.log.logfile_dir STRING var/log/trafficserver
    :reloadable:
 
-   The full path to the logging directory. This can be an absolute path or a path relative to the directory in which Traffic Server is installed.
+   The path to the logging directory. This can be an absolute path
+   or a path relative to the ``PREFIX`` directory in which Traffic
+   Server is installed.
 
    .. note:: The directory you specify must already exist.