You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2014/01/03 18:18:36 UTC

[05/50] git commit: TS-2448: Fix traffic_cop to work correctly if proxy.config.local_state_dir is set

TS-2448: Fix traffic_cop to work correctly if proxy.config.local_state_dir is set


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

Branch: refs/heads/5.0.x
Commit: b78aa56acccb74b3a507fd8642fdb847b34f76bf
Parents: 2772ae6
Author: James Peach <jp...@apache.org>
Authored: Mon Dec 16 15:51:32 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Fri Dec 20 15:23:09 2013 -0800

----------------------------------------------------------------------
 cmd/traffic_cop/traffic_cop.cc | 62 ++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b78aa56a/cmd/traffic_cop/traffic_cop.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
index 21ea7d1..088be6a 100644
--- a/cmd/traffic_cop/traffic_cop.cc
+++ b/cmd/traffic_cop/traffic_cop.cc
@@ -61,9 +61,7 @@ static const char COP_TRACE_FILE[] = "/tmp/traffic_cop.trace";
 #define COP_WARNING  LOG_ERR
 #define COP_DEBUG    LOG_DEBUG
 
-static const char *root_dir;
 static const char *runtime_dir;
-static const char *config_dir;
 static char config_file[PATH_NAME_MAX];
 
 static char cop_lockfile[PATH_NAME_MAX];
@@ -1704,45 +1702,13 @@ init_signals()
 }
 
 static void
-init_config_dir()
-{
-
-  struct stat info;
-
-  cop_log_trace("Entering init_config_dir()\n");
-
-  root_dir = Layout::get()->prefix;
-  runtime_dir = config_read_runtime_dir();
-  config_dir = Layout::get()->sysconfdir;
-
-  if (chdir(root_dir) < 0) {
-    cop_log(COP_FATAL, "unable to change to root directory \"%s\" [%d '%s']\n", root_dir, errno, strerror(errno));
-    cop_log(COP_FATAL," please set correct path in env variable TS_ROOT \n");
-    exit(1);
-  }
-
-  if (stat(config_dir, &info) < 0) {
-    cop_log(COP_FATAL, "unable to locate config directory '%s'\n",config_dir);
-    cop_log(COP_FATAL, " please try setting correct root path in env variable TS_ROOT \n");
-    exit(1);
-  }
-
-  if (stat(runtime_dir, &info) < 0) {
-    cop_log(COP_FATAL, "unable to locate local state directory '%s'\n",runtime_dir);
-    cop_log(COP_FATAL, " please try setting correct root path in either env variable TS_ROOT \n");
-    exit(1);
-  }
-  cop_log_trace("Leaving init_config_dir()\n");
-}
-
-static void
 init_lockfiles()
 {
 
   cop_log_trace("Entering init_lockfiles()\n");
-  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile), Layout::get()->runtimedir, COP_LOCK);
-  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile), Layout::get()->runtimedir, MANAGER_LOCK);
-  Layout::relative_to(server_lockfile, sizeof(server_lockfile), Layout::get()->runtimedir, SERVER_LOCK);
+  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile), runtime_dir, COP_LOCK);
+  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile), runtime_dir, MANAGER_LOCK);
+  Layout::relative_to(server_lockfile, sizeof(server_lockfile), runtime_dir, SERVER_LOCK);
 
   cop_log_trace("Leaving init_lockfiles()\n");
 }
@@ -1757,8 +1723,17 @@ static void
 init_config_file()
 {
   struct stat info;
+  const char * config_dir;
 
   cop_log_trace("Entering init_config_file()\n");
+
+  config_dir = Layout::get()->sysconfdir;
+  if (stat(config_dir, &info) < 0) {
+    cop_log(COP_FATAL, "unable to locate config directory '%s'\n",config_dir);
+    cop_log(COP_FATAL, " please try setting correct root path in env variable TS_ROOT \n");
+    exit(1);
+  }
+
   Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config.shadow");
   if (stat(config_file, &info) < 0) {
     Layout::relative_to(config_file, sizeof(config_file), config_dir, "records.config");
@@ -1773,6 +1748,8 @@ init_config_file()
 static void
 init()
 {
+  struct stat info;
+
   cop_log_trace("Entering init()\n");
 
   RecConfigFileInit();
@@ -1780,9 +1757,16 @@ init()
   init_signals();
   init_syslog();
 
-  init_config_dir();
-
   init_config_file();
+  config_reload_records();
+
+  runtime_dir = config_read_runtime_dir();
+  if (stat(runtime_dir, &info) < 0) {
+    cop_log(COP_FATAL, "unable to locate local state directory '%s'\n",runtime_dir);
+    cop_log(COP_FATAL, " please try setting correct root path in either env variable TS_ROOT \n");
+    exit(1);
+  }
+
   init_lockfiles();
   check_lockfile();