You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2018/05/10 12:04:34 UTC
[trafficserver] branch master updated: Remove traffic_cop
This is an automated email from the ASF dual-hosted git repository.
shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 41fe21b Remove traffic_cop
41fe21b is described below
commit 41fe21b2cf00161515cdfb8471b25880276c85bf
Author: Susan Hinrichs <sh...@oath.com>
AuthorDate: Tue May 8 12:15:22 2018 +0000
Remove traffic_cop
---
CMakeLists.txt | 4 -
README | 1 -
cmd/Makefile.am | 1 -
cmd/traffic_cop/Makefile.am | 45 -
cmd/traffic_cop/traffic_cop.cc | 1767 --------------------
cmd/traffic_ctl/config.cc | 2 -
cmd/traffic_manager/Makefile.am | 2 -
cmd/traffic_manager/MgmtHandlers.cc | 285 ----
cmd/traffic_manager/MgmtHandlers.h | 29 -
cmd/traffic_manager/traffic_manager.cc | 36 +-
configure.ac | 1 -
doc/admin-guide/files/records.config.en.rst | 62 +-
doc/admin-guide/installation/index.en.rst | 5 +-
doc/admin-guide/introduction.en.rst | 15 +-
doc/admin-guide/logging/understanding.en.rst | 3 +-
doc/appendices/command-line/traffic_cop.en.rst | 70 -
doc/appendices/faq.en.rst | 18 -
.../api/types/TSRecordUpdateType.en.rst | 4 -
doc/developer-guide/config-vars.en.rst | 3 -
doc/developer-guide/core-architecture/rpc.en.rst | 3 +-
doc/manpages.py | 1 -
lib/records/I_RecDefs.h | 1 -
lib/records/RecLocal.cc | 5 -
lib/ts/BaseLogFile.cc | 2 +-
lib/ts/apidefs.h.in | 1 -
mgmt/RecordsConfig.cc | 24 +-
mgmt/WebMgmtUtils.cc | 2 +-
proxy/Main.cc | 8 -
proxy/ReverseProxy.cc | 6 -
proxy/http/HttpConfig.cc | 9 -
proxy/http/HttpConfig.h | 7 -
proxy/http/HttpSM.cc | 51 +-
proxy/http/HttpTransact.cc | 90 +-
proxy/http/HttpTransact.h | 1 -
proxy/http/remap/UrlRewrite.cc | 2 -
proxy/http/remap/UrlRewrite.h | 3 -
rc/trafficserver.conf.in | 2 +-
rc/trafficserver.in | 63 +-
rc/trafficserver.service.in | 2 +-
rc/trafficserver.xml.in | 2 +-
tests/gold_tests/basic/basic-cop.test.py | 32 -
41 files changed, 94 insertions(+), 2576 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5f910ad..537fe03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,10 +55,6 @@ include_directories(lib
proxy/api
lib/luajit/src)
-add_executable(traffic_cop
- cmd/traffic_cop/traffic_cop.cc
-)
-
add_executable(traffic_crashlog
cmd/traffic_crashlog/procinfo.cc
cmd/traffic_crashlog/traffic_crashlog.cc
diff --git a/README b/README
index 1c44fd7..964deb5 100644
--- a/README
+++ b/README
@@ -9,7 +9,6 @@ plugins to build large scale web applications.
traffic/ ............... top src dir
|-- ci/ ................ quality assurance and other CI tools and configs
|-- cmd/ ............... various command applications
- |-- traffic_cop/ ..
|-- traffic_crashlog/
|-- traffic_ctl/ ... traffic_ctl command line management application
|-- traffic_layout/
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 481631d..d7a0888 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -17,7 +17,6 @@
SUBDIRS = \
traffic_cache_tool \
- traffic_cop \
traffic_crashlog \
traffic_ctl \
traffic_layout \
diff --git a/cmd/traffic_cop/Makefile.am b/cmd/traffic_cop/Makefile.am
deleted file mode 100644
index e2da4ad..0000000
--- a/cmd/traffic_cop/Makefile.am
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Makefile.am for the Enterprise Management module.
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-AM_CPPFLAGS += \
- $(iocore_include_dirs) \
- -I$(abs_top_srcdir)/lib \
- -I$(abs_top_srcdir)/lib/records \
- -I$(abs_top_srcdir)/mgmt \
- -I$(abs_top_srcdir)/mgmt/api/include \
- $(TS_INCLUDES)
-
-AM_LDFLAGS += \
- @OPENSSL_LDFLAGS@
-
-bin_PROGRAMS = traffic_cop
-
-traffic_cop_SOURCES = \
- traffic_cop.cc
-
-traffic_cop_LDADD = \
- $(top_builddir)/mgmt/libmgmt_c.la \
- $(top_builddir)/mgmt/api/libtsmgmt.la \
- $(top_builddir)/lib/ts/libtsutil.la \
- $(top_builddir)/lib/records/librecords_cop.a
-
-include $(top_srcdir)/build/tidy.mk
-
-clang-tidy-local: $(DIST_SOURCES)
- $(CXX_Clang_Tidy)
diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc
deleted file mode 100644
index 325e2ec..0000000
--- a/cmd/traffic_cop/traffic_cop.cc
+++ /dev/null
@@ -1,1767 +0,0 @@
-/** @file
-
- Main entry point for the traffic_cop application.
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include "ts/ink_platform.h"
-#include "ts/ink_syslog.h"
-#include "ts/ink_stack_trace.h"
-#include "ts/ink_lockfile.h"
-#include "ts/ink_sock.h"
-#include "ts/ink_args.h"
-#include "ts/ink_file.h"
-#include "ts/I_Layout.h"
-#include "ts/I_Version.h"
-#include "I_RecCore.h"
-#include "mgmtapi.h"
-#include "RecordsConfig.h"
-#include "ts/ink_cap.h"
-#include "Cop.h"
-#include "ts/runroot.h"
-
-#include <string>
-#include <map>
-
-#if defined(linux) || defined(solaris)
-#include "sys/utsname.h"
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-union semun {
- int val; /* value for SETVAL */
- struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
- unsigned short int *array; /* array for GETALL, SETALL */
- struct seminfo *__buf; /* buffer for IPC_INFO */
-};
-#endif // linux check
-#include <grp.h>
-
-static const int MAX_LOGIN = ink_login_name_max();
-
-#define OPTIONS_MAX 32
-#define OPTIONS_LEN_MAX 1024
-
-#ifndef WAIT_ANY
-#define WAIT_ANY (pid_t) - 1
-#endif // !WAIT_ANY
-
-#define COP_FATAL LOG_ALERT
-#define COP_WARNING LOG_ERR
-#define COP_DEBUG LOG_DEBUG
-#define COP_NOTICE LOG_NOTICE
-
-static const char *runtime_dir;
-static char config_file[PATH_NAME_MAX];
-
-static char cop_lockfile[PATH_NAME_MAX];
-static char manager_lockfile[PATH_NAME_MAX];
-static char server_lockfile[PATH_NAME_MAX];
-
-static int check_memory_min_swapfree_kb = 0;
-static int check_memory_min_memfree_kb = 0;
-
-static int syslog_facility = LOG_DAEMON;
-static char syslog_fac_str[PATH_NAME_MAX] = "LOG_DAEMON";
-
-static int killsig = SIGKILL;
-static int coresig = 0;
-
-static int debug_flag = false;
-static int stdout_flag = false;
-static int stop_flag = false;
-
-static char *admin_user;
-static uid_t admin_uid;
-static gid_t admin_gid;
-static bool admin_user_p = false;
-static char manager_binary[PATH_NAME_MAX] = "traffic_manager";
-static char server_binary[PATH_NAME_MAX] = "traffic_server";
-
-static char log_file[PATH_NAME_MAX] = "traffic.out";
-
-static int synthetic_port = 8083;
-static int http_backdoor_port = 8084;
-
-#if defined(linux)
-// TS-1075 : auto-port ::connect DoS on high traffic linux systems
-static int source_port = 0;
-#endif
-
-static int manager_failures = 0;
-static int server_failures = 0;
-static int server_not_found = 0;
-static int init_sleep_time = cop_sleep_time; // 10 sec
-
-/* This gets setup when loading the configuration */
-typedef enum {
- COP_KILL_NONE = 0,
- COP_KILL_SERVER = 1,
- COP_KILL_MANAGER = 2,
-} ActiveHealthChecks;
-
-static int active_health_checks = COP_KILL_SERVER | COP_KILL_MANAGER;
-
-// traffic_manager flap detection
-#define MANAGER_FLAP_DETECTION 1
-#if defined(MANAGER_FLAP_DETECTION)
-#define MANAGER_MAX_FLAP_COUNT 3 // if flap this many times, give up for a while
-#define MANAGER_FLAP_INTERVAL_MSEC 60000 // if x number of flaps happen in this interval, declare flapping
-#define MANAGER_FLAP_RETRY_MSEC 60000 // if flapping, don't try to restart until after this retry duration
-static bool manager_flapping = false; // is the manager flapping?
-static int manager_flap_count = 0; // how many times has the manager flapped?
-static ink_hrtime manager_flap_interval_start_time = 0; // first time we attempted to start the manager in past little while)
-static ink_hrtime manager_flap_retry_start_time = 0; // first time we attempted to start the manager in past little while)
-#endif
-
-// transient syscall error timeout
-#define TRANSIENT_ERROR_WAIT_MS 500
-
-static int child_pid = 0;
-static int child_status = 0;
-
-AppVersionInfo appVersionInfo;
-
-static const char localhost[] = "127.0.0.1";
-
-static void cop_log(int priority, const char *format, ...) TS_PRINTFLIKE(2, 3);
-
-static void get_admin_user();
-
-struct ConfigValue {
- ConfigValue() : config_type(RECT_NULL), data_type(RECD_NULL) {}
- ConfigValue(RecT _t, RecDataT _d, const std::string &_v) : config_type(_t), data_type(_d), data_value(_v) {}
- RecT config_type;
- RecDataT data_type;
- std::string data_value;
-};
-
-typedef std::map<std::string, ConfigValue> ConfigValueTable;
-static ConfigValueTable configTable;
-
-#define cop_log_trace(...) \
- do { \
- if (debug_flag) \
- cop_log(COP_DEBUG, __VA_ARGS__); \
- } while (0)
-
-static const char *
-priority_name(int priority)
-{
- switch (priority) {
- case COP_DEBUG:
- return "DEBUG";
- case COP_WARNING:
- return "WARNING";
- case COP_FATAL:
- return "FATAL";
- case COP_NOTICE:
- return "NOTICE";
- default:
- return "unknown";
- }
-}
-
-static void
-cop_log(int priority, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
-
- if (stdout_flag) {
- struct timeval now;
- double now_f;
-
- now = ink_gettimeofday();
- now_f = now.tv_sec + now.tv_usec / 1000000.0f;
-
- fprintf(stdout, "<%.4f> [%s]: ", now_f, priority_name(priority));
- vfprintf(stdout, format, args);
- fflush(stdout);
- } else {
- char buffer[8192];
- vsprintf(buffer, format, args);
- syslog(priority, "%s", buffer);
- }
-
- va_end(args);
-}
-
-void
-chown_file_to_admin_user(const char *file)
-{
- if (admin_user_p) {
- if (chown(file, admin_uid, admin_gid) < 0 && errno != ENOENT) {
- cop_log(COP_FATAL, "cop couldn't chown the file: '%s' for '%s' (%d/%d) : [%d] %s\n", file, admin_user, admin_uid, admin_gid,
- errno, strerror(errno));
- }
- }
-}
-
-static void
-sig_child(int signum)
-{
- pid_t pid = 0;
- int status = 0;
-
- cop_log_trace("Entering sig_child(%d)\n", signum);
- for (;;) {
- pid = waitpid(WAIT_ANY, &status, WNOHANG);
-
- if (pid <= 0) {
- break;
- }
- // TSqa03086 - We can not log the child status signal from
- // the signal handler since syslog can deadlock. Record
- // the pid and the status in a global for logging
- // next time through the event loop. We will occasionally
- // lose some information if we get two sig childs in rapid
- // succession
- child_pid = pid;
- child_status = status;
- }
- cop_log_trace("Leaving sig_child(%d)\n", signum);
-}
-
-static void
-sig_term(int signum)
-{
- pid_t pid = 0;
- int status = 0;
-
- // killsig = SIGTERM;
-
- cop_log_trace("Entering sig_term(%d)\n", signum);
-
- // safely^W commit suicide.
- cop_log_trace("Sending signal %d to entire group\n", signum);
- killpg(0, signum);
-
- cop_log_trace("Waiting for children to exit.");
-
- for (;;) {
- pid = waitpid(WAIT_ANY, &status, WNOHANG);
-
- if (pid <= 0) {
- break;
- }
- // TSqa03086 - We can not log the child status signal from
- // the signal handler since syslog can deadlock. Record
- // the pid and the status in a global for logging
- // next time through the event loop. We will occasionally
- // lose some information if we get two sig childs in rapid
- // succession
- child_pid = pid;
- child_status = status;
- }
- cop_log_trace("Leaving sig_term(%d), exiting traffic_cop\n", signum);
- _exit(0);
-}
-
-static void
-#if defined(solaris)
-sig_fatal(int signum, siginfo_t *t, void *c)
-#else
-sig_fatal(int signum)
-#endif
-{
- cop_log_trace("Entering sig_fatal(%d)\n", signum);
-#if defined(solaris)
- if (t) {
- if (t->si_code <= 0) {
- cop_log(COP_FATAL,
- "cop received fatal user signal [%d] from"
- " pid [%d] uid [%d]\n",
- signum, (int)(t->si_pid), t->si_uid);
- } else {
- cop_log(COP_FATAL,
- "cop received fatal kernel signal [%d], "
- "reason [%d]\n",
- signum, t->si_code);
- }
- } else {
-#endif
- cop_log(COP_FATAL, "cop received fatal signal [%d]\n", signum);
-#if defined(solaris)
- }
-#endif
- ink_stack_trace_dump();
- cop_log_trace("Leaving sig_fatal(%d)\n", signum);
- abort();
-}
-
-static void
-#if defined(solaris)
-sig_alarm_warn(int signum, siginfo_t *t, void *c)
-#else
-sig_alarm_warn(int signum)
-#endif
-{
- cop_log_trace("Entering sig_alarm_warn(%d)\n", signum);
- cop_log(COP_WARNING, "unable to kill traffic_server for the last %d seconds\n", cop_kill_timeout);
-
- // Set us up for another alarm
- alarm(cop_kill_timeout);
- cop_log_trace("Leaving sig_alarm_warn(%d)\n", signum);
-}
-
-static void
-sig_ignore(int signum)
-{
- cop_log_trace("Entering sig_ignore(%d)\n", signum);
- // No code here yet...
- cop_log_trace("Leaving sig_ignore(%d)\n", signum);
-}
-
-static void
-set_alarm_death()
-{
- struct sigaction action;
-
- cop_log_trace("Entering set_alarm_death()\n");
-#if defined(solaris)
- action.sa_handler = nullptr;
- action.sa_sigaction = sig_fatal;
- sigemptyset(&action.sa_mask);
- action.sa_flags = SA_SIGINFO;
-#else
- action.sa_handler = sig_fatal;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-#endif
-
- sigaction(SIGALRM, &action, nullptr);
- cop_log_trace("Leaving set_alarm_death()\n");
-}
-
-static void
-set_alarm_warn()
-{
- struct sigaction action;
-
- cop_log_trace("Entering set_alarm_warn()\n");
-#if defined(solaris)
- action.sa_handler = nullptr;
- action.sa_sigaction = sig_alarm_warn;
- sigemptyset(&action.sa_mask);
- action.sa_flags = SA_SIGINFO;
-#else
- action.sa_handler = sig_alarm_warn;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-#endif
-
- sigaction(SIGALRM, &action, nullptr);
- cop_log_trace("Leaving set_alarm_warn()\n");
-}
-
-static void
-process_syslog_config()
-{
- int new_fac;
-
- cop_log_trace("Entering process_syslog_config()\n");
- new_fac = facility_string_to_int(syslog_fac_str);
-
- if (new_fac >= 0 && new_fac != syslog_facility) {
- closelog();
- openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, new_fac);
- syslog_facility = new_fac;
- }
- cop_log_trace("Leaving process_syslog_config()\n");
-}
-
-// Paranoia: wrap the process termination call within alarms
-// so that when the killing call doesn't return we
-// will still wake up
-static void
-safe_kill(const char *lockfile_name, const char *pname, bool group)
-{
- Lockfile lockfile(lockfile_name);
- chown_file_to_admin_user(lockfile_name);
-
- cop_log_trace("Entering safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
- set_alarm_warn();
- alarm(cop_kill_timeout);
-
- if (group == true) {
- lockfile.KillGroup(killsig, coresig, pname);
- } else {
- lockfile.Kill(killsig, coresig, pname);
- }
- chown_file_to_admin_user(lockfile_name);
-
- alarm(0);
- set_alarm_death();
- cop_log_trace("Leaving safe_kill(%s, %s, %d)\n", lockfile_name, pname, group);
-}
-
-// ink_hrtime milliseconds()
-//
-// Returns the result of gettimeofday converted to
-// one 64bit int
-//
-static ink_hrtime
-milliseconds()
-{
- struct timeval now;
-
- cop_log_trace("Entering milliseconds()\n");
- now = ink_gettimeofday();
- // Make liberal use of casting to ink_hrtime to ensure the
- // compiler does not truncate our result
- cop_log_trace("Leaving milliseconds()\n");
- return ((ink_hrtime)now.tv_sec * 1000) + ((ink_hrtime)now.tv_usec / 1000);
-}
-
-static void
-millisleep(int ms)
-{
- struct timespec ts;
-
- cop_log_trace("Entering millisleep(%d)\n", ms);
- ts.tv_sec = ms / 1000;
- ts.tv_nsec = (ms - ts.tv_sec * 1000) * 1000 * 1000;
- nanosleep(&ts, nullptr);
- cop_log_trace("Leaving millisleep(%d)\n", ms);
-}
-
-static bool
-transient_error(int error, int wait_ms)
-{
- cop_log_trace("Entering transient_error(%d, %d)\n", error, wait_ms);
-
- // switch cases originally from UnixNex::accept_error_seriousness()
- switch (error) {
- case EAGAIN:
- case EINTR:
- break;
-
- case ENFILE:
- case EMFILE:
- case ENOMEM:
-#ifdef ENOBUFS
- case ENOBUFS:
-#endif
-#if defined(ENOSR) && !defined(freebsd) && !defined(darwin)
- case ENOSR:
-#endif
- if (wait_ms) {
- millisleep(wait_ms);
- }
- break;
-
- default:
- cop_log_trace("Leaving transient_error(%d, %d) --> false\n", error, wait_ms);
- return false;
- }
- cop_log_trace("Leaving transient_error(%d, %d) --> true\n", error, wait_ms);
- return true;
-}
-
-static void
-config_register_variable(RecT rec_type, RecDataT data_type, const char *name, const char *value, RecSourceT /* source */,
- bool /* inc_version */)
-{
- configTable[std::string(name)] = ConfigValue(rec_type, data_type, value);
-}
-
-static void
-config_register_default(const RecordElement *record, void *)
-{
- if (record->type == RECT_CONFIG || record->type == RECT_LOCAL) {
- const char *value = record->value ? record->value : ""; // splooch nullptr values so std::string can swallow them
- configTable[std::string(record->name)] = ConfigValue(record->type, record->value_type, value);
- }
-}
-
-static void
-config_read_string(const char *name, char *val, size_t val_len, bool miss_ok = false)
-{
- ConfigValueTable::const_iterator config;
-
- config = configTable.find(name);
- if (config == configTable.end()) {
- if (miss_ok) {
- return;
- } else {
- goto ConfigStrFatalError;
- }
- }
-
- if (config->second.data_type != RECD_STRING) {
- goto ConfigStrFatalError;
- }
-
- ink_strlcpy(val, RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()), val_len);
- return;
-
-ConfigStrFatalError:
- cop_log(COP_FATAL, "could not find string variable %s in records.config\n", name);
- exit(1);
-}
-
-static void
-config_read_int(const char *name, int *val, bool miss_ok = false)
-{
- ConfigValueTable::const_iterator config;
-
- config = configTable.find(name);
- if (config == configTable.end()) {
- if (miss_ok) {
- return;
- } else {
- goto ConfigIntFatalError;
- }
- }
-
- if (config->second.data_type != RECD_INT) {
- goto ConfigIntFatalError;
- }
-
- *val = atoi(RecConfigOverrideFromEnvironment(name, config->second.data_value.c_str()));
- return;
-
-ConfigIntFatalError:
- cop_log(COP_FATAL, "could not find integer variable %s in records.config\n", name);
- exit(1);
-}
-
-static std::string
-config_read_runtime_dir()
-{
- char state_dir[PATH_NAME_MAX];
-
- 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 Layout::get()->runtimedir;
- }
-}
-
-static std::string
-config_read_sysconfig_dir()
-{
- char sysconfig_dir[PATH_NAME_MAX];
-
- sysconfig_dir[0] = '\0';
- config_read_string("proxy.config.config_dir", sysconfig_dir, sizeof(sysconfig_dir), true);
- if (strlen(sysconfig_dir) > 0) {
- return Layout::get()->relative(sysconfig_dir);
- } else {
- return Layout::get()->sysconfdir;
- }
-}
-
-static std::string
-config_read_bin_dir()
-{
- char bindir[PATH_NAME_MAX];
-
- bindir[0] = '\0';
- config_read_string("proxy.config.bin_path", bindir, sizeof(bindir), true);
- cop_log(COP_DEBUG, "binpath is %s\n", bindir);
- if (strlen(bindir) > 0) {
- return Layout::get()->relative(bindir);
- } else {
- return Layout::get()->bindir;
- }
-}
-
-static std::string
-config_read_log_dir()
-{
- char logdir[PATH_NAME_MAX];
-
- logdir[0] = '\0';
- config_read_string("proxy.config.log.logfile_dir", logdir, sizeof(logdir), true);
- if (strlen(logdir) > 0) {
- return Layout::get()->relative(logdir);
- } else {
- return Layout::get()->logdir;
- }
-}
-
-static void
-config_reload_records()
-{
- struct stat stat_buf;
- static time_t last_mod = 0;
- char log_filename[PATH_NAME_MAX];
- int tmp_int = 3;
-
- std::string bindir;
- std::string logdir;
-
- cop_log_trace("Entering %s()\n", __func__);
- // coverity[fs_check_call]
- if (stat(config_file, &stat_buf) == -1) {
- cop_log(COP_FATAL, "could not stat \"%s\"\n", config_file);
- exit(1);
- }
-
- if (stat_buf.st_mtime <= last_mod) { // no change, no need to re-read
- return;
- } else {
- last_mod = stat_buf.st_mtime;
- }
-
- configTable.clear();
- RecordsConfigIterate(config_register_default, nullptr);
-
- if (RecConfigFileParse(config_file, config_register_variable, false) != REC_ERR_OKAY) {
- cop_log(COP_FATAL, "could not parse \"%s\"\n", config_file);
- exit(1);
- }
-
- config_read_string("proxy.config.manager_binary", manager_binary, sizeof(manager_binary), true);
- config_read_string("proxy.config.proxy_binary", server_binary, sizeof(server_binary), true);
- get_admin_user();
-
- bindir = config_read_bin_dir();
- if (access(bindir.c_str(), R_OK) == -1) {
- cop_log(COP_FATAL, "could not access() \"%s\"\n", bindir.c_str());
- cop_log(COP_FATAL, "please set 'proxy.config.bin_path' \n");
- exit(1);
- }
-
- logdir = config_read_log_dir();
- if (access(logdir.c_str(), W_OK) == -1) {
- cop_log(COP_FATAL, "could not access() \"%s\"\n", logdir.c_str());
- cop_log(COP_FATAL, "please set 'proxy.config.log.logfile_dir' \n");
- exit(1);
- }
-
- config_read_string("proxy.config.output.logfile", log_filename, sizeof(log_filename));
- Layout::relative_to(log_file, sizeof(log_file), logdir, log_filename);
-
- config_read_int("proxy.config.process_manager.mgmt_port", &http_backdoor_port, true);
- config_read_int("proxy.config.admin.synthetic_port", &synthetic_port, true);
- config_read_int("proxy.config.cop.init_sleep_time", &init_sleep_time, true);
-
- config_read_int("proxy.config.cop.active_health_checks", &tmp_int, true);
- // 0 == No servers are killed
- // 1 == Only traffic_manager can be killed on failure
- // 2 == Only traffic_server can be killed on failure
- // 3 == Any failing healthchecks can cause restarts (default)
- switch (tmp_int) {
- case 0:
- active_health_checks = COP_KILL_NONE;
- break;
- case 1:
- active_health_checks = COP_KILL_MANAGER;
- break;
- case 2:
- active_health_checks = COP_KILL_SERVER;
- break;
- default:
- active_health_checks = COP_KILL_SERVER | COP_KILL_MANAGER;
- break;
- }
-
-#if defined(linux)
- // TS-1075 : auto-port ::connect DoS on high traffic linux systems
- config_read_int("proxy.config.cop.source_port", &source_port, true);
-#endif
-
- if (stdout_flag) {
- config_read_string("proxy.config.syslog_facility", syslog_fac_str, sizeof(syslog_fac_str), true);
- process_syslog_config();
- }
-
- config_read_int("proxy.config.cop.core_signal", &coresig, true);
-
- config_read_int("proxy.config.cop.linux_min_swapfree_kb", &check_memory_min_swapfree_kb, true);
- config_read_int("proxy.config.cop.linux_min_memfree_kb", &check_memory_min_memfree_kb, true);
-
- cop_log_trace("Leaving %s()\n", __func__);
-}
-
-static void
-get_admin_user()
-{
- struct passwd *pwd = nullptr;
-
- if (!admin_user) {
- admin_user = (char *)ats_malloc(MAX_LOGIN);
- }
-
- config_read_string("proxy.config.admin.user_id", admin_user, MAX_LOGIN);
-
- if (*admin_user) {
- char *end = admin_user + strlen(admin_user) - 1;
-
- // Trim trailing spaces.
- while (end >= admin_user && isspace(*end)) {
- end--;
- }
- *(end + 1) = '\0';
-
- if (*admin_user == '#') {
- int uid = atoi(admin_user + 1);
- if (uid == -1) {
- // XXX: Can this call hapen after setuid?
- uid = (int)geteuid();
- }
- pwd = getpwuid((uid_t)uid);
- } else {
- pwd = getpwnam(admin_user);
- }
-
- if (pwd) {
- admin_uid = pwd->pw_uid;
- admin_gid = pwd->pw_gid;
- admin_user_p = true;
- } else {
- cop_log(COP_FATAL, "can't get passwd entry for the admin user '%s' - [%d] %s\n", admin_user, errno, strerror(errno));
- exit(1);
- }
- }
-}
-
-static void
-spawn_manager()
-{
- char prog[PATH_NAME_MAX];
- std::string bindir(config_read_bin_dir());
-
- cop_log_trace("Entering spawn_manager()\n");
-
- Layout::relative_to(prog, sizeof(prog), bindir, manager_binary);
- if (access(prog, R_OK | X_OK) == -1) {
- cop_log(COP_FATAL, "unable to access() manager binary \"%s\" [%d '%s']\n", prog, errno, strerror(errno));
- exit(1);
- }
-
- // Move any traffic.out that we can not write to, out
- // of the way (TSqa2232)
- // coverity[fs_check_call]
- if (access(log_file, W_OK) < 0 && errno == EACCES) {
- char old_log_file[PATH_NAME_MAX];
- snprintf(old_log_file, sizeof(old_log_file), "%s.old", log_file);
- cop_log(COP_NOTICE, "renaming %s to %s as it is not writeable\n", log_file, old_log_file);
- // coverity[toctou]
- if (rename(log_file, old_log_file) != 0) {
- cop_log(COP_WARNING, "unable to rename \"%s\" to \"%s\" [%d '%s']\n", log_file, old_log_file, errno, strerror(errno));
- }
- }
-
- cop_log_trace("launching %s'\n", prog);
-
- pid_t child = fork();
- if (child == 0) {
- EnableDeathSignal(SIGTERM);
-
- // Bind stdout and stderr of traffic_manager to traffic.out
- execl(prog, prog, "--" TM_OPT_BIND_STDOUT, log_file, "--" TM_OPT_BIND_STDERR, log_file, nullptr);
- cop_log_trace("Somehow execv(%s, options, nullptr) failed: %s (%d)!\n", prog, strerror(errno), errno);
- exit(1);
- } else if (child == -1) {
- cop_log(COP_FATAL, "unable to fork [%d '%s']\n", errno, strerror(errno));
- exit(1);
- }
-
- manager_failures = 0;
- cop_log_trace("Leaving spawn_manager()\n");
-}
-
-static int
-poll_read_or_write(int fd, int timeout, int inorout)
-{
- struct pollfd info;
- int err;
-
- info.fd = fd;
- info.events = inorout;
- info.revents = 0;
-
- do {
- err = poll(&info, 1, timeout);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if ((err > 0) && (info.revents & inorout)) {
- return 1;
- }
-
- return err;
-}
-
-inline static int
-poll_read(int fd, int timeout)
-{
- return poll_read_or_write(fd, timeout, POLLIN);
-}
-
-inline static int
-poll_write(int fd, int timeout)
-{
- return poll_read_or_write(fd, timeout, POLLOUT);
-}
-
-static int
-open_socket(int port, const char *ip = nullptr, const char *ip_to_bind = nullptr)
-{
- int sock = 0;
- struct addrinfo hints;
- struct addrinfo *result = nullptr;
- struct addrinfo *result_to_bind = nullptr;
- char port_str[8] = {'\0'};
- int err = 0;
-
- cop_log_trace("Entering open_socket(%d, %s, %s)\n", port, ip, ip_to_bind);
- if (!ip) {
- ip = localhost;
- }
-
-#if defined(linux)
- // TS-1075 : auto-port ::connect DoS on high traffic linux systems
- // unbound connections are "unsafe" in high connection count environments
- if (!ip_to_bind) {
- ip = localhost;
- }
-#endif
-
- snprintf(port_str, sizeof(port_str), "%d", port);
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
-
- err = getaddrinfo(ip, port_str, &hints, &result);
- if (err != 0) {
- cop_log(COP_WARNING, "(test) unable to get address info [%d %s] at ip %s, port %s\n", err, gai_strerror(err), ip, port_str);
- goto getaddrinfo_error;
- }
-
- // Create a socket
- do {
- sock = socket(result->ai_family, result->ai_socktype, 0);
- } while ((sock < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if (sock < 0) {
- cop_log(COP_WARNING, "(test) unable to create socket [%d '%s']\n", errno, strerror(errno));
- goto error;
- }
-
- if (ip_to_bind) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = result->ai_family;
- hints.ai_socktype = result->ai_socktype;
-
- err = getaddrinfo(ip_to_bind, nullptr, &hints, &result_to_bind);
- if (err != 0) {
- cop_log(COP_WARNING, "(test) unable to get address info [%d %s] at ip %s\n", err, gai_strerror(err), ip_to_bind);
- freeaddrinfo(result_to_bind);
- goto error;
- }
-
-#if defined(linux)
- // TS-1075 : auto-port ::connect DoS on high traffic linux systems
- // Bash the port on ::bind so that we always use the same port
- if (0 != source_port) {
- if (result_to_bind->ai_addr->sa_family == AF_INET) {
- ((sockaddr_in *)result_to_bind->ai_addr)->sin_port = htons(source_port);
- } else {
- ((sockaddr_in6 *)result_to_bind->ai_addr)->sin6_port = htons(source_port);
- }
-
- // also set REUSEADDR so that previous cop connections in the TIME_WAIT state
- // do not interfere
- if (safe_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int)) < 0) {
- cop_log(COP_WARNING, "(test) unable to set REUSEADDR socket option [%d '%s']\n", errno, strerror(errno));
- }
- }
-#endif
-
- if (safe_bind(sock, result_to_bind->ai_addr, result_to_bind->ai_addrlen) < 0) {
- cop_log(COP_WARNING, "(test) unable to bind socket [%d '%s']\n", errno, strerror(errno));
- }
-
- freeaddrinfo(result_to_bind);
- }
-
- // Put the socket in non-blocking mode...just to be extra careful
- // that we never block.
- do {
- err = fcntl(sock, F_SETFL, O_NONBLOCK);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if (err < 0) {
- cop_log(COP_WARNING, "(test) unable to put socket in non-blocking mode [%d '%s']\n", errno, strerror(errno));
- goto error;
- }
- // Connect to the specified port on the machine we're running on.
- do {
- err = connect(sock, result->ai_addr, result->ai_addrlen);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if ((err < 0) && (errno != EINPROGRESS)) {
- cop_log(COP_WARNING, "(test) unable to connect to server [%d '%s'] at port %d\n", errno, strerror(errno), port);
- goto error;
- }
- cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, sock);
- freeaddrinfo(result);
- return sock;
-
-error:
- if (sock >= 0) {
- close_socket(sock);
- }
- cop_log_trace("Leaving open_socket(%d, %s, %s) --> %d\n", port, ip, ip_to_bind, -1);
-getaddrinfo_error:
- freeaddrinfo(result);
- return -1;
-}
-
-static int
-test_port(int port, const char *request, char *buffer, int bufsize, int64_t test_timeout, const char *ip = nullptr,
- const char *ip_to_bind = nullptr)
-{
- int64_t start_time, timeout;
- int sock;
- size_t length = strlen(request);
- int64_t err, idx;
-
- start_time = milliseconds();
-
- sock = open_socket(port, ip, ip_to_bind);
- if (sock < 0) {
- goto error;
- }
-
- timeout = milliseconds() - start_time;
- if (timeout >= test_timeout) {
- cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
- goto error;
- }
- timeout = test_timeout - timeout;
-
- err = poll_write(sock, timeout);
- if (err < 0) {
- cop_log(COP_WARNING, "(test) poll write failed [%d '%s']\n", errno, strerror(errno));
- goto error;
- } else if (err == 0) {
- cop_log(COP_WARNING, "(test) write timeout [%" PRId64 " ms]\n", timeout);
- goto error;
- }
- // Write the request to the server.
- while (length > 0) {
- do {
- err = write(sock, request, length);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if (err < 0) {
- cop_log(COP_WARNING, "(test) write failed [%d '%s']\n", errno, strerror(errno));
- goto error;
- }
-
- request += err;
- length -= err;
- }
-
- idx = 0;
- for (;;) {
- if (idx >= bufsize) {
- cop_log(COP_WARNING, "(test) response is too large [%" PRId64 "]\n", idx);
- goto error;
- }
-
- timeout = milliseconds() - start_time;
- if (timeout >= test_timeout) {
- cop_log(COP_WARNING, "(test) timeout occurred [%" PRId64 " ms]\n", timeout);
- goto error;
- }
- timeout = test_timeout - timeout;
-
- err = poll_read(sock, timeout);
- if (err < 0) {
- cop_log(COP_WARNING, "(test) poll read failed [%d '%s']\n", errno, strerror(errno));
- goto error;
- } else if (err == 0) {
- cop_log(COP_WARNING, "(test) read timeout [%" PRId64 " ]\n", timeout);
- goto error;
- }
-
- do {
- err = read(sock, &buffer[idx], bufsize - idx);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if (err < 0) {
- cop_log(COP_WARNING, "(test) read failed [%d '%s']\n", errno, strerror(errno));
- goto error;
- } else if (err == 0) {
- buffer[idx] = '\0';
- close(sock);
- return 0;
- } else {
- idx += err;
- }
- }
-
-error:
- if (sock >= 0) {
- close_socket(sock);
- }
- return -1;
-}
-
-static int
-read_mgmt_cli_int(const char *variable, int *value)
-{
- TSInt val;
-
- if (TSRecordGetInt(variable, &val) != TS_ERR_OKAY) {
- cop_log(COP_WARNING, "(cli test) could not communicate with mgmt cli\n");
- return -1;
- }
- *value = val;
- return 0;
-}
-
-static int
-test_mgmt_cli_port()
-{
- TSString val = nullptr;
- int ret = 0;
-
- if (TSRecordGetString("proxy.config.manager_binary", &val) != TS_ERR_OKAY) {
- cop_log(COP_WARNING, "(cli test) unable to retrieve manager_binary\n");
- ret = -1;
- } else {
- if (strcmp(val, manager_binary) != 0) {
- cop_log(COP_WARNING, "(cli test) bad response value, got %s, expected %s\n", val, manager_binary);
- ret = -1;
- }
- }
-
- if (val) {
- TSfree(val);
- }
- return ret;
-}
-
-static int
-test_http_port(int port, char *request, int timeout, const char *ip = nullptr, char const *ip_to_bind = nullptr)
-{
- char buffer[4096];
- char *p;
- int err;
-
- err = test_port(port, request, buffer, 4095, timeout, ip, ip_to_bind);
- if (err < 0) {
- return err;
- }
-
- p = buffer;
-
- if (strncmp(p, "HTTP/", 5) != 0) {
- cop_log(COP_WARNING, "(http test) received malformed response\n");
- return -1;
- }
-
- p += 5;
- while (*p && !isspace(*p)) {
- p += 1;
- }
-
- while (*p && isspace(*p)) {
- p += 1;
- }
-
- if (strncmp(p, "200", 3) != 0) {
- char pstatus[4] = {0};
- ink_strlcpy(pstatus, p, sizeof(pstatus));
- cop_log(COP_WARNING, "(http test) received non-200 status(%s)\n", pstatus);
- return -1;
- }
-
- p = strstr(p, "\r\n\r\n");
- if (!p) {
- cop_log(COP_WARNING, "(http test) could not find end of header\n");
- return -1;
- }
-
- p += 4;
- while (*p) {
- if (strncmp(p, "abcdefghijklmnopqrstuvwxyz", 26) != 0) {
- cop_log(COP_WARNING, "(http test) corrupted response data\n");
- return -1;
- }
-
- p += 26;
- while (*p && (*p != '\n')) {
- p += 1;
- }
- p += 1;
- }
-
- return 0;
-}
-
-static int
-test_server_http_port()
-{
- char request[1024] = {'\0'};
-
- // Generate a request for a the 'synthetic.txt' document the manager
- // servers up on the autoconf port.
- snprintf(request, sizeof(request), "GET http://127.0.0.1:%d/synthetic.txt HTTP/1.0\r\n\r\n", synthetic_port);
-
- return test_http_port(http_backdoor_port, request, cop_server_timeout * 1000, localhost, localhost);
-}
-
-static int
-heartbeat_manager()
-{
- int err;
-
- cop_log_trace("Entering heartbeat_manager()\n");
- // the CLI.
- err = test_mgmt_cli_port();
-
- if (err < 0) {
- // See heartbeat_server()'s comments for how we determine a server/manager failure.
- manager_failures += 1;
- cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
-
- if (manager_failures > 1) {
- manager_failures = 0;
- if (active_health_checks & COP_KILL_MANAGER) {
- cop_log(COP_WARNING, "killing manager\n");
- safe_kill(manager_lockfile, manager_binary, true);
- } else {
- cop_log(COP_WARNING, "would have killed manager, but configuration said not to\n");
- }
- }
- cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
- return err;
- }
-
- cop_log_trace("Leaving heartbeat_manager() --> %d\n", err);
- return err;
-}
-
-static int
-heartbeat_server()
-{
- int err;
-
- cop_log_trace("Entering heartbeat_server()\n");
- err = test_server_http_port();
-
- if (err < 0) {
- // If the test failed, increment the count of the number of
- // failures. We don't kill the server the first time the test
- // fails because we might just have gotten caught in a race
- // where we decided to do the test because we thought the
- // server was up even though somebody was in the process of
- // bringing it down. The "server_up" function will reset
- // 'server_failures' if it determines the server is down.
-
- server_failures += 1;
- cop_log(COP_WARNING, "server heartbeat failed [%d]\n", server_failures);
-
- // If this is the second time that the server test has failed
- // we kill the server.
- if (server_failures > 1) {
- server_failures = 0;
- // TSqa02622: Change the ALRM signal handler while
- // trying to kill the process since if a core
- // is being written, it could take a long time
- // Set a new alarm so that we can print warnings
- // if it is taking too long to kill the server
- //
- if (active_health_checks & COP_KILL_SERVER) {
- cop_log(COP_WARNING, "killing server\n");
- safe_kill(server_lockfile, server_binary, false);
- // Allow a configurable longer sleep init time
- // to load very large remap files
- cop_log_trace("performing additional sleep for %d sec during init", init_sleep_time);
- millisleep(init_sleep_time * 1000);
- } else {
- cop_log(COP_WARNING, "would have killed server, but configurations said not to\n");
- }
- }
- } else {
- if (server_failures) {
- cop_log(COP_WARNING, "server heartbeat succeeded\n");
- }
- server_failures = 0;
- }
-
- cop_log_trace("Leaving heartbeat_server() --> %d\n", err);
- return err;
-}
-
-static int
-server_up()
-{
- static int old_val = 0;
- int val = -1;
- int err;
-
- cop_log_trace("Entering server_up()\n");
- err = read_mgmt_cli_int("proxy.node.proxy_running", &val);
-
- if (err < 0) {
- cop_log(COP_WARNING, "could not contact manager, assuming server is down\n");
- cop_log_trace("Leaving server_up() --> 0\n");
- return 0;
- }
-
- if (val != old_val) {
- server_failures = 0;
- server_not_found = 0;
- old_val = val;
- }
-
- if (val == 1) {
- cop_log_trace("Leaving server_up() --> 1\n");
- return 1;
- } else {
- cop_log_trace("Leaving server_up() --> 0\n");
- return 0;
- }
-}
-
-// | state | status | action
-// --------|---------|----------|---------------
-// manager | up | ok | nothing
-// server | up | ok |
-// --------|---------|----------|---------------
-// manager | up | bad | kill manager
-// server | up | ? |
-// --------|---------|----------|---------------
-// manager | up | ok | kill manager
-// server | down | ? |
-// --------|---------|----------|---------------
-// manager | up | ok | kill server
-// server | up | bad |
-
-static void
-check_programs()
-{
- int err;
- pid_t holding_pid;
-
- cop_log_trace("Entering check_programs()\n");
-
- // Try to get the manager lock file. If we succeed in doing this,
- // it means there is no manager running.
- Lockfile manager_lf(manager_lockfile);
- err = manager_lf.Open(&holding_pid);
- chown_file_to_admin_user(manager_lockfile);
-
- if (err > 0) {
- // 'lockfile_open' returns the file descriptor of the opened
- // lockfile. We need to close this before spawning the
- // manager so that the manager can grab the lock.
- manager_lf.Close();
-
-#if !defined(MANAGER_FLAP_DETECTION)
- // Make sure we don't have a stray traffic server running.
- cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
- safe_kill(server_lockfile, server_binary, false);
- // Spawn the manager.
- cop_log(COP_WARNING, "spawning traffic_manager\n");
- spawn_manager();
-#else
- // Make sure we don't have a stray traffic server running.
- if (!manager_flapping) {
- cop_log(COP_WARNING, "traffic_manager not running, making sure traffic_server is dead\n");
- safe_kill(server_lockfile, server_binary, false);
- }
- // Spawn the manager (check for flapping manager too)
- ink_hrtime now = milliseconds();
- if (!manager_flapping) {
- if ((manager_flap_interval_start_time == 0) || (now - manager_flap_interval_start_time > MANAGER_FLAP_INTERVAL_MSEC)) {
- // either:
- // . it's our first time through
- // . we were flapping a while ago, but we would
- // like to retry now
- // . it's been a while since we last tried to start
- // traffic_manager
- manager_flap_count = 0;
- }
- if (manager_flap_count >= MANAGER_MAX_FLAP_COUNT) {
- // we've flapped too many times, hold off for a while
- cop_log(COP_WARNING, "unable to start traffic_manager, retrying in %d second(s)\n", MANAGER_FLAP_RETRY_MSEC / 1000);
- manager_flapping = true;
- manager_flap_retry_start_time = now;
- } else {
- // try to spawn traffic_manager
- cop_log(COP_WARNING, "spawning traffic_manager\n");
- spawn_manager();
- // track spawn attempt
- if (manager_flap_count == 0) {
- manager_flap_interval_start_time = now;
- }
- manager_flap_count++;
- }
- } else {
- // we were flapping, take some time off and don't call
- // spawn_manager
- if (now - manager_flap_retry_start_time > MANAGER_FLAP_RETRY_MSEC) {
- manager_flapping = false;
- manager_flap_interval_start_time = 0;
- }
- }
-#endif
- } else {
- // If there is a manager running we want to heartbeat it to
- // make sure it hasn't wedged. If the manager test succeeds we
- // check to see if the server is up. (That is, it hasn't been
- // brought down via the UI). If the manager thinks the server
- // is up, we make sure there is actually a server process
- // running. If there is we test it.
-
- alarm(2 * cop_manager_timeout);
- err = heartbeat_manager();
- alarm(0);
-
- if (err < 0) {
- return;
- }
-
- if (server_up() <= 0) {
- return;
- }
-
- Lockfile server_lf(server_lockfile);
- err = server_lf.Open(&holding_pid);
-
- if (err > 0) {
- server_lf.Close();
-
- server_not_found += 1;
- cop_log(COP_WARNING, "cannot find traffic_server [%d]\n", server_not_found);
-
- if (server_not_found > 1) {
- server_not_found = 0;
- cop_log(COP_WARNING, "killing manager\n");
- safe_kill(manager_lockfile, manager_binary, true);
- }
- } else {
- alarm(2 * cop_server_timeout);
- heartbeat_server();
- alarm(0);
- }
- }
- cop_log_trace("Leaving check_programs()\n");
-}
-
-static void
-check_memory()
-{
- // TODO: We need to take care of other systems, ie bsd, solaris.
- // And we should try to summarize whether the swapping is really
- // putting the server under memory pressure. Or should we check
- // the process memory usage of the server & manager?
- cop_log_trace("Entering check_memory()\n");
-#if defined(linux)
- if (check_memory_min_swapfree_kb > 0 || check_memory_min_memfree_kb > 0) {
- FILE *fp;
- char buf[LINE_MAX];
- long long memfree, swapfree, swapsize;
- memfree = swapfree = swapsize = 0;
- if ((fp = fopen("/proc/meminfo", "r"))) {
- while (fgets(buf, sizeof buf, fp)) {
- if (strncmp(buf, "MemFree:", sizeof "MemFree:" - 1) == 0) {
- memfree = strtoll(buf + sizeof "MemFree:" - 1, nullptr, 10);
- } else if (strncmp(buf, "SwapFree:", sizeof "SwapFree:" - 1) == 0) {
- swapfree = strtoll(buf + sizeof "SwapFree:" - 1, nullptr, 10);
- } else if (strncmp(buf, "SwapTotal:", sizeof "SwapTotal:" - 1) == 0) {
- swapsize = strtoll(buf + sizeof "SwapTotal:" - 1, nullptr, 10);
- }
- }
- fclose(fp);
- // simple heuristic for linux
- // swapsize swapfree memfree
- // 1: >0 low high (bad)
- // 2: >0 high low (okay)
- // 3: >0 low low (bad; covered by 1)
- // 4: 0 0 high (okay)
- // 5: 0 0 low (bad)
- if ((swapsize != 0 && swapfree < check_memory_min_swapfree_kb) || (swapsize == 0 && memfree < check_memory_min_memfree_kb)) {
- cop_log(COP_WARNING, "Low memory available (swap: %dkB, mem: %dkB)\n", (int)swapfree, (int)memfree);
- if (active_health_checks & COP_KILL_MANAGER) {
- cop_log(COP_WARNING, "Killing '%s'\n", manager_binary);
- manager_failures = 0;
- safe_kill(manager_lockfile, manager_binary, true);
- } else {
- cop_log(COP_WARNING, "would have killed manager due to low memory, but configurations sayd not to\n");
- }
- if (active_health_checks & COP_KILL_SERVER) {
- cop_log(COP_WARNING, "Killing '%s'\n", server_binary);
- server_failures = 0;
- safe_kill(server_lockfile, server_binary, false);
- } else {
- cop_log(COP_WARNING, "would have killed server due to low memory, but configurations sayd not to\n");
- }
- }
- } else {
- cop_log(COP_WARNING, "Unable to open /proc/meminfo: %s\n", strerror(errno));
- }
- }
-#endif
- cop_log_trace("Leaving check_memory()\n");
-}
-
-static int
-check_no_run()
-{
- char path[PATH_NAME_MAX];
- struct stat info;
- int err;
-
- cop_log_trace("Entering check_no_run()\n");
- snprintf(path, sizeof(path), "%s/no_cop", runtime_dir);
-
- do {
- err = stat(path, &info);
- } while ((err < 0) && (transient_error(errno, TRANSIENT_ERROR_WAIT_MS)));
-
- if (err < 0) {
- cop_log_trace("Leaving check_no_run() --> 0\n");
- return 0;
- }
-
- cop_log(COP_WARNING, "encountered \"%s\" file...exiting\n", path);
- cop_log_trace("Leaving check_no_run() --> -1\n");
- return -1;
-}
-
-// Changed function from taking no argument and returning void
-// to taking a void* and returning a void*. The change was made
-// so that we can call ink_thread_create() on this function
-// in the case of running cop as a win32 service.
-static void *
-check(void *arg)
-{
- bool mgmt_init = false;
- cop_log_trace("Entering check()\n");
-
- for (;;) {
- // problems with the ownership of this file as root Make sure it is
- // owned by the admin user
- chown_file_to_admin_user(manager_lockfile);
- chown_file_to_admin_user(server_lockfile);
-
- alarm(2 * (cop_sleep_time + cop_manager_timeout * 2 + cop_server_timeout));
-
- if (check_no_run() < 0) {
- break;
- }
- // Log any SIGCLD singals we received
- if (child_pid > 0) {
- if (WIFEXITED(child_status) == 0) {
- // Child terminated abnormally
- cop_log(COP_WARNING, "cop received non-normal child status signal [%d %d]\n", child_pid, WEXITSTATUS(child_status));
- } else {
- // normal termination
- cop_log(COP_WARNING, "cop received child status signal [%d %d]\n", child_pid, child_status);
- }
- if (WIFSIGNALED(child_status)) {
- int sig = WTERMSIG(child_status);
- cop_log(COP_WARNING, "child terminated due to signal %d: %s\n", sig, strsignal(sig));
- }
-
- child_pid = 0;
- child_status = 0;
- }
-
- // Re-read the config file information
- config_reload_records();
-
- // Check to make sure the programs are running
- check_programs();
-
- // Check to see if we're running out of free memory
- check_memory();
-
- // Pause to catch our breath. (10 seconds).
- // Use 'millisleep()' because normal 'sleep()' interferes with
- // the SIGALRM signal which we use to heartbeat the cop.
- millisleep(cop_sleep_time * 1000);
-
- // We do this after the first round of checks, since the first "check" will spawn traffic_manager
- if (!mgmt_init) {
- std::string runtimedir(config_read_runtime_dir());
- TSInit(runtimedir.c_str(), static_cast<TSInitOptionT>(TS_MGMT_OPT_NO_EVENTS));
- mgmt_init = true;
-
- // Allow a configurable longer sleep init time
- // to load very large remap files
- cop_log_trace("performing additional sleep for %d sec during init", init_sleep_time);
- millisleep(init_sleep_time * 1000);
- }
- }
-
- // Done with the mgmt API.
- TSTerminate();
-
- cop_log_trace("Leaving check()\n");
- return arg;
-}
-
-static void
-check_lockfile()
-{
- int err;
- pid_t holding_pid;
-
- cop_log_trace("Entering check_lockfile()\n");
- Lockfile cop_lf(cop_lockfile);
- err = cop_lf.Get(&holding_pid);
- if (err < 0) {
- cop_log(COP_WARNING, "periodic cop heartbeat couldn't open '%s' (errno %d)\n", cop_lockfile, -err);
- exit(1);
- } else if (err == 0) {
- cop_log(COP_DEBUG, "periodic heartbeat successful, another cop still on duty\n");
- exit(1);
- }
-
- cop_log(COP_NOTICE, "--- Cop Starting [Version: %s] ---\n", appVersionInfo.FullVersionInfoStr);
- cop_log_trace("Leaving check_lockfile()\n");
-}
-
-static void
-init_signals()
-{
- struct sigaction action;
-
- cop_log_trace("Entering init_signals()\n");
- // Handle the SIGTERM and SIGINT signal:
- // We kill the process group and wait() for all children
- action.sa_handler = sig_term;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-
- sigaction(SIGTERM, &action, nullptr);
- sigaction(SIGINT, &action, nullptr);
-
- // Handle the SIGCHLD signal. We simply reap all children that
- // die (which should only be spawned traffic_manager's).
- action.sa_handler = sig_child;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-
- sigaction(SIGCHLD, &action, nullptr);
-
-// Handle a bunch of fatal signals. We simply call abort() when
-// these signals arrive in order to generate a core. There is some
-// difficulty with generating core files when linking with libthread
-// under solaris.
-#if defined(solaris)
- action.sa_handler = nullptr;
- action.sa_sigaction = sig_fatal;
-#else
- action.sa_handler = sig_fatal;
-#endif
- sigemptyset(&action.sa_mask);
-#if defined(solaris)
- action.sa_flags = SA_SIGINFO;
-#else
- action.sa_flags = 0;
-#endif
-
- sigaction(SIGQUIT, &action, nullptr);
- sigaction(SIGILL, &action, nullptr);
- sigaction(SIGFPE, &action, nullptr);
- sigaction(SIGBUS, &action, nullptr);
- sigaction(SIGSEGV, &action, nullptr);
-#if !defined(linux)
- sigaction(SIGEMT, &action, nullptr);
- sigaction(SIGSYS, &action, nullptr);
-#endif
-
- // Handle the SIGALRM signal. We use this signal to make sure the
- // cop never wedges. It gets reset every time through its loop. If
- // the alarm ever expires we treat it as a fatal signal and dump
- // core, secure in the knowledge we'll get restarted.
- set_alarm_death();
-
- action.sa_handler = sig_ignore;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
-
- sigaction(SIGPIPE, &action, nullptr);
- cop_log_trace("Leaving init_signals()\n");
-}
-
-static void
-init_lockfiles()
-{
- cop_log_trace("Entering init_lockfiles()\n");
- 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");
-}
-
-inline static void
-init_syslog()
-{
- openlog("traffic_cop", LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON);
-}
-
-static void
-init_config_file()
-{
- struct stat info;
- std::string config_dir;
-
- cop_log_trace("Entering init_config_file()\n");
-
- config_dir = config_read_sysconfig_dir();
- if (stat(config_dir.c_str(), &info) < 0) {
- cop_log(COP_FATAL, "unable to locate config directory '%s'\n", config_dir.c_str());
- 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");
- if (stat(config_file, &info) < 0) {
- cop_log(COP_FATAL, "unable to locate \"%s/records.config\" or \"%s/records.config.shadow\"\n", config_dir.c_str(),
- config_dir.c_str());
- exit(1);
- }
- }
- cop_log_trace("Leaving init_config_file()\n");
-}
-
-static void
-init()
-{
- struct stat info;
-
- cop_log_trace("Entering init()\n");
-
- // Start up the records store and load the defaults so that we can locate our configuration.
- RecConfigFileInit();
- RecordsConfigIterate(config_register_default, nullptr);
-
- init_signals();
- init_syslog();
-
- init_config_file();
- config_reload_records();
-
- runtime_dir = ats_stringdup(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();
-
- cop_log_trace("Leaving init()\n");
-}
-
-static const ArgumentDescription argument_descriptions[] = {
- {"debug", 'd', "Enable debug logging", "F", &debug_flag, nullptr, nullptr},
- {"stdout", 'o', "Print log messages to standard output", "F", &stdout_flag, nullptr, nullptr},
- {"stop", 's', "Send child processes SIGSTOP instead of SIGKILL", "F", &stop_flag, nullptr, nullptr},
- HELP_ARGUMENT_DESCRIPTION(),
- VERSION_ARGUMENT_DESCRIPTION(),
- RUNROOT_ARGUMENT_DESCRIPTION()};
-
-int
-main(int /* argc */, const char *argv[])
-{
- int fd;
- appVersionInfo.setup(PACKAGE_NAME, "traffic_cop", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
-
- runroot_handler(argv);
- // Before accessing file system initialize Layout engine
- Layout::create();
-
- process_args(&appVersionInfo, argument_descriptions, countof(argument_descriptions), argv);
-
- if (stop_flag) {
- cop_log_trace("Cool! I think I'll be a STOP cop!");
- killsig = SIGSTOP;
- }
-
- signal(SIGHUP, SIG_IGN);
- signal(SIGTSTP, SIG_IGN);
- signal(SIGTTOU, SIG_IGN);
- signal(SIGTTIN, SIG_IGN);
-
- // setup supplementary groups if it is not set. any way, worth a try.
- if (0 == getgroups(0, nullptr)) {
- uid_t uid = getuid();
- gid_t gid = getgid();
-
- const int bufSize = 1024;
- char buf[bufSize];
-
- struct passwd passwdInfo;
- struct passwd *ppasswd = nullptr;
- int res;
- res = getpwuid_r(uid, &passwdInfo, buf, bufSize, &ppasswd);
- if (!res && ppasswd) {
- initgroups(ppasswd->pw_name, gid);
- }
- }
-
- setsid(); // Important, thanks Vlad. :)
-#if (defined(freebsd) && !defined(kfreebsd)) || defined(openbsd)
- setpgrp(0, 0);
-#else
- setpgrp();
-#endif
-
- // Detach STDIN, STDOUT, and STDERR (basically, "nohup"). /leif
- if (!stdout_flag) {
- if ((fd = open("/dev/null", O_WRONLY, 0)) >= 0) {
- if ((dup2(fd, STDIN_FILENO)) < 0) {
- ink_fputln(stderr, "Unable to detach stdin");
- return 0;
- }
- if ((dup2(fd, STDOUT_FILENO)) < 0) {
- ink_fputln(stderr, "Unable to detach stdout");
- return 0;
- }
- if ((dup2(fd, STDERR_FILENO)) < 0) {
- ink_fputln(stderr, "Unable to detach stderr");
- return 0;
- }
- close(fd);
- } else {
- ink_fputln(stderr, "Unable to open /dev/null");
- return 0;
- }
- }
-
- // Initialize and start it up.
- init();
- check(nullptr);
-
- return 0;
-}
diff --git a/cmd/traffic_ctl/config.cc b/cmd/traffic_ctl/config.cc
index cc846db..42fdccc 100644
--- a/cmd/traffic_ctl/config.cc
+++ b/cmd/traffic_ctl/config.cc
@@ -115,8 +115,6 @@ rec_updateof(int rec_updatetype)
return "static, restart traffic_server";
case RECU_RESTART_TM:
return "static, restart traffic_manager";
- case RECU_RESTART_TC:
- return "static, full restart";
case RECU_NULL: /* fallthru */
default:
return "none";
diff --git a/cmd/traffic_manager/Makefile.am b/cmd/traffic_manager/Makefile.am
index 2c1ec47..a3a20cc 100644
--- a/cmd/traffic_manager/Makefile.am
+++ b/cmd/traffic_manager/Makefile.am
@@ -43,8 +43,6 @@ AM_LDFLAGS += \
traffic_manager_SOURCES = \
AddConfigFilesHere.cc \
- MgmtHandlers.cc \
- MgmtHandlers.h \
metrics.h \
traffic_manager.cc
diff --git a/cmd/traffic_manager/MgmtHandlers.cc b/cmd/traffic_manager/MgmtHandlers.cc
deleted file mode 100644
index b2e3951..0000000
--- a/cmd/traffic_manager/MgmtHandlers.cc
+++ /dev/null
@@ -1,285 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/****************************************************************************
- *
- * WebIntrMain.cc - main loop for the Web Interface
- *
- ****************************************************************************/
-
-#include "ts/ink_platform.h"
-#include "ts/ink_sock.h"
-#include "ts/I_Layout.h"
-#include "LocalManager.h"
-#include "Alarms.h"
-#include "MgmtUtils.h"
-#include "MgmtSocket.h"
-#include "NetworkUtilsRemote.h"
-#include "MIME.h"
-#include "Cop.h"
-
-// INKqa09866
-#include "TSControlMain.h"
-#include "EventControlMain.h"
-
-int aconf_port_arg = -1;
-
-// fd newTcpSocket(int port)
-//
-// returns a file descriptor associated with a new socket
-// on the specified port
-//
-// If the socket could not be created, returns -1
-//
-// Thread Safe: NO! Call only from main Web interface thread
-//
-static int
-newTcpSocket(int port)
-{
- struct sockaddr_in socketInfo;
- int socketFD;
- int one = 1;
-
- memset(&socketInfo, 0, sizeof(sockaddr_in));
-
- // Create the new TCP Socket
- if ((socketFD = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
- mgmt_fatal(errno, "[newTcpSocket]: %s", "Unable to Create Socket\n");
- return -1;
- }
- // Specify our port number is network order
- memset(&socketInfo, 0, sizeof(socketInfo));
- socketInfo.sin_family = AF_INET;
- socketInfo.sin_port = htons(port);
- socketInfo.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
- // Allow for immediate re-binding to port
- if (setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(int)) < 0) {
- mgmt_fatal(errno, "[newTcpSocket] Unable to set socket options.\n");
- }
- // Bind the port to the socket
- if (bind(socketFD, (sockaddr *)&socketInfo, sizeof(socketInfo)) < 0) {
- mgmt_log("[newTcpSocket] Unable to bind port %d to socket: %s\n", port, strerror(errno));
- close_socket(socketFD);
- return -1;
- }
- // Listen on the new socket
- if (listen(socketFD, 5) < 0) {
- mgmt_elog(errno, "[newTcpSocket] %s\n", "Unable to listen on the socket");
- close_socket(socketFD);
- return -1;
- }
- // Set the close on exec flag so our children do not
- // have this socket open
- if (fcntl(socketFD, F_SETFD, FD_CLOEXEC) < 0) {
- mgmt_elog(errno, "[newTcpSocket] Unable to set close on exec flag\n");
- }
-
- return socketFD;
-}
-
-bool
-api_socket_is_restricted()
-{
- RecInt intval;
-
- // If the socket is not administratively restricted, check whether we have platform
- // support. Otherwise, default to making it restricted.
- if (RecGetRecordInt("proxy.config.admin.api.restricted", &intval) == REC_ERR_OKAY) {
- if (intval == 0) {
- return !mgmt_has_peereid();
- }
- }
-
- return true;
-}
-
-static const char SyntheticResponse[] = "HTTP/1.0 200 OK\r\n"
- "Server: Traffic Manager\r\n"
- "Date: %s\r\n"
- "Cache-Control: no-store\r\n"
- "Pragma: no-cache\r\n"
- "Content-type: text/plain\r\n"
- "Content-Length: %d\r\n\r\n%s%s%s";
-
-static const char SyntheticData[] = "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n"
- "abcdefghijklmnopqrstuvwxyz\r\n";
-
-static const char RequestStr[] = "GET /synthetic.txt HTTP/1"; // Minimum viable request that we support
-
-void *
-synthetic_thread(void *info)
-{
- char buffer[4096];
- char dateBuf[128];
- char *bufp;
- int clientFD = *(int *)info;
- ssize_t bytes;
- size_t len = 0;
-
- // Read the request
- bufp = buffer;
- while (len < strlen(RequestStr)) {
- if (read_ready(clientFD, cop_server_timeout * 1000) <= 0) {
- mgmt_log("[SyntheticHealthServer] poll() failed, no request to read()");
- goto error;
- }
- bytes = read(clientFD, buffer, sizeof(buffer));
- if (0 == bytes) {
- mgmt_log("[SyntheticHealthServer] EOF on the socket, likely prematurely closed");
- goto error;
- } else if (bytes < 0) {
- if (errno == EINTR || errno == EAGAIN) {
- continue;
- } else {
- mgmt_log("[SyntheticHealthServer] Failed to read the request");
- goto error;
- }
- } else {
- len += bytes;
- bufp += bytes;
- }
- }
-
- // Bare minimum check if the request looks reasonable (i.e. from traffic_cop)
- if (len < strlen(RequestStr) || 0 != strncasecmp(buffer, RequestStr, strlen(RequestStr))) {
- mgmt_log("[SyntheticHealthServer] Unsupported request provided");
- goto error;
- }
-
- // Format the response
- mime_format_date(dateBuf, time(nullptr));
- len = snprintf(buffer, sizeof(buffer), SyntheticResponse, dateBuf, (int)strlen(SyntheticData) * 3, SyntheticData, SyntheticData,
- SyntheticData);
-
- // Write it
- bufp = buffer;
- while (len) {
- if (write_ready(clientFD, cop_server_timeout * 1000) <= 0) {
- mgmt_log("[SyntheticHealthServer] poll() failed, no response to write()");
- goto error;
- }
- bytes = write(clientFD, buffer, len);
- if (bytes < 0) {
- if (errno == EINTR || errno == EAGAIN) {
- continue;
- } else {
- mgmt_log("[SyntheticHealthServer] Failed to write the response");
- goto error;
- }
- } else {
- len -= bytes;
- bufp += bytes;
- }
- }
-
-error:
- close_socket(clientFD);
- ink_thread_exit(nullptr);
-
- return nullptr;
-}
-
-void *
-mgmt_synthetic_main(void *)
-{
- int autoconfFD = -1; // FD for incoming autoconf connections
- int clientFD = -1; // FD for accepted connections
- int publicPort = -1; // Port for incoming autoconf connections
-
-#if !defined(linux)
- sigset_t allSigs; // Set of all signals
-#endif
-
- RecInt tempInt;
- bool found;
-
-#if !defined(linux)
- // Start by blocking all signals
- sigfillset(&allSigs);
- ink_thread_sigsetmask(SIG_SETMASK, &allSigs, nullptr);
-#endif
-
- if (aconf_port_arg > 0) {
- publicPort = aconf_port_arg;
- } else {
- found = (RecGetRecordInt("proxy.config.admin.synthetic_port", &tempInt) == REC_ERR_OKAY);
- ink_release_assert(found);
- publicPort = (int)tempInt;
- }
- Debug("ui", "[WebIntrMain] Starting Client AutoConfig Server on Port %d", publicPort);
-
- if ((autoconfFD = newTcpSocket(publicPort)) < 0) {
- mgmt_elog(errno, "[WebIntrMain] Unable to start client autoconf server\n");
- lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_WEB_ERROR, "Healthcheck service failed to initialize");
- }
-
- while (true) {
- struct sockaddr_in clientInfo; // Info about client connection
- socklen_t addrLen = sizeof(clientInfo);
-
- ink_zero(clientInfo);
- if ((clientFD = mgmt_accept(autoconfFD, (sockaddr *)&clientInfo, &addrLen)) < 0) {
- mgmt_log("[SyntheticHealthServer] accept() on incoming port failed: %s\n", strerror(errno));
- } else if (safe_setsockopt(clientFD, IPPROTO_TCP, TCP_NODELAY, SOCKOPT_ON, sizeof(int)) < 0) {
- mgmt_log("[SyntheticHealthServer] Failed to set sock options: %s\n", strerror(errno));
- close_socket(clientFD);
- } else if (clientInfo.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) {
- mgmt_log("[SyntheticHealthServer] Connect by disallowed client %s, closing\n", inet_ntoa(clientInfo.sin_addr));
- close_socket(clientFD);
- } else {
- ink_thread_create(nullptr, synthetic_thread, (void *)&clientFD, 1, 0, nullptr);
- }
- }
-
- ink_release_assert(!"impossible"); // should never get here
- return nullptr;
-}
-
-/*
- HTTP/1.0 200 OK
- Server: Traffic Manager
- Date: Wed, 10 Jun 2015 04:28:07 GMT
- Cache-Control: no-store
- Pragma: no-cache
- Content-type: text/plain
- Content-length: 1620
-*/
diff --git a/cmd/traffic_manager/MgmtHandlers.h b/cmd/traffic_manager/MgmtHandlers.h
deleted file mode 100644
index 72b8f2a..0000000
--- a/cmd/traffic_manager/MgmtHandlers.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#pragma once
-
-extern int aconf_port_arg;
-
-void *mgmt_synthetic_main(void *);
-bool api_socket_is_restricted();
diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc
index c9e3cfe..2866270 100644
--- a/cmd/traffic_manager/traffic_manager.cc
+++ b/cmd/traffic_manager/traffic_manager.cc
@@ -31,6 +31,7 @@
#include "WebMgmtUtils.h"
#include "MgmtUtils.h"
+#include "MgmtSocket.h"
#include "NetworkUtilsRemote.h"
#include "FileManager.h"
#include "ts/I_Layout.h"
@@ -44,8 +45,6 @@
#include "TSControlMain.h"
#include "EventControlMain.h"
-#include "MgmtHandlers.h"
-
// Needs LibRecordsConfigInit()
#include "RecordsConfig.h"
@@ -450,6 +449,22 @@ millisleep(int ms)
nanosleep(&ts, nullptr); // we use nanosleep instead of sleep because it does not interact with signals
}
+bool
+api_socket_is_restricted()
+{
+ RecInt intval;
+
+ // If the socket is not administratively restricted, check whether we have platform
+ // support. Otherwise, default to making it restricted.
+ if (RecGetRecordInt("proxy.config.admin.api.restricted", &intval) == REC_ERR_OKAY) {
+ if (intval == 0) {
+ return !mgmt_has_peereid();
+ }
+ }
+
+ return true;
+}
+
int
main(int argc, const char **argv)
{
@@ -469,24 +484,20 @@ main(int argc, const char **argv)
// TODO: This seems completely incomplete, disabled for now
// int dump_config = 0, dump_process = 0, dump_node = 0, dump_local = 0;
char *proxy_port = nullptr;
- int proxy_backdoor = -1;
char *tsArgs = nullptr;
int disable_syslog = false;
char userToRunAs[MAX_LOGIN + 1];
RecInt fds_throttle = -1;
- ink_thread synthThrId;
int binding_version = 0;
BindingInstance *binding = nullptr;
ArgumentDescription argument_descriptions[] = {
{"proxyOff", '-', "Disable proxy", "F", &proxy_off, nullptr, nullptr},
- {"aconfPort", '-', "Autoconf port", "I", &aconf_port_arg, "MGMT_ACONF_PORT", nullptr},
{"path", '-', "Path to the management socket", "S*", &mgmt_path, nullptr, nullptr},
{"recordsConf", '-', "Path to records.config", "S*", &recs_conf, nullptr, nullptr},
{"tsArgs", '-', "Additional arguments for traffic_server", "S*", &tsArgs, nullptr, nullptr},
{"proxyPort", '-', "HTTP port descriptor", "S*", &proxy_port, nullptr, nullptr},
- {"proxyBackDoor", '-', "Management port", "I", &proxy_backdoor, nullptr, nullptr},
{TM_OPT_BIND_STDOUT, '-', "Regular file to bind stdout to", "S512", &bind_stdout, "PROXY_BIND_STDOUT", nullptr},
{TM_OPT_BIND_STDERR, '-', "Regular file to bind stderr to", "S512", &bind_stderr, "PROXY_BIND_STDERR", nullptr},
#if TS_USE_DIAGS
@@ -661,23 +672,10 @@ main(int argc, const char **argv)
HttpProxyPort::loadValue(lmgmt->m_proxy_ports, proxy_port);
}
- if (proxy_backdoor != -1) {
- RecSetRecordInt("proxy.config.process_manager.mgmt_port", proxy_backdoor, REC_SOURCE_DEFAULT);
- }
-
lmgmt->initMgmtProcessServer(); /* Setup p-to-p process server */
lmgmt->listenForProxy();
- //
- // As listenForProxy() may change/restore euid, we should put
- // the creation of mgmt_synthetic_main thread after it. So that we
- // can keep a consistent euid when create mgmtapi/eventapi unix
- // sockets in mgmt_synthetic_main thread.
- //
- ink_thread_create(&synthThrId, mgmt_synthetic_main, nullptr, 0, 0, nullptr); /* Spin web agent thread */
- Debug("lm", "Created Web Agent thread (%" PRId64 ")", (int64_t)synthThrId);
-
// Setup the API and event sockets
std::string rundir(RecConfigReadRuntimeDir());
std::string apisock(Layout::relative_to(rundir, MGMTAPI_MGMT_SOCKET_NAME));
diff --git a/configure.ac b/configure.ac
index bc6929c..07bc06e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2030,7 +2030,6 @@ AC_CONFIG_FILES([
Makefile
cmd/Makefile
cmd/traffic_cache_tool/Makefile
- cmd/traffic_cop/Makefile
cmd/traffic_crashlog/Makefile
cmd/traffic_ctl/Makefile
cmd/traffic_layout/Makefile
diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index dfd0da8..f301370 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -168,7 +168,7 @@ not be affected by future configuration changes made in
For example, we could override the `proxy.config.product_company`_ variable
like this::
- $ PROXY_CONFIG_PRODUCT_COMPANY=example traffic_cop &
+ $ PROXY_CONFIG_PRODUCT_COMPANY=example traffic_manager &
$ traffic_ctl config get proxy.config.product_company
.. _configuration-variables:
@@ -235,49 +235,6 @@ System Variables
:ref:`admin-logging-understanding` for more in-depth discussion
of the contents and interpretations of log files.
-.. ts:cv:: CONFIG proxy.config.cop.core_signal INT 0
-
- The signal sent to :program:`traffic_cop`'s managed processes to stop them.
-
- A value of ``0`` means no signal will be sent.
-
-.. ts:cv:: CONFIG proxy.config.cop.linux_min_memfree_kb INT 0
-
- The minimum amount of free memory space allowed before Traffic Server stops
- the :program:`traffic_server` and :program:`traffic_manager` processes to
- prevent the system from hanging.
-
-.. ts:cv:: CONFIG proxy.config.cop.linux_min_swapfree_kb INT 0
-
- The minimum amount of free swap space allowed before Traffic Server stops
- the :program:`traffic_server` and :program:`traffic_manager` processes to
- prevent the system from hanging. This configuration variable applies if
- swap is enabled in Linux 2.2 only.
-
-.. ts:cv:: CONFIG proxy.config.cop.init_sleep_time INT 0
-
- The minimum amount of addtional duration allowed before Traffic Server detects
- that the :program:`traffic_server` is not responsive and attempts a restart
- during startup. This configuration variable allows Traffic Server a longer init
- time to load potentially large configuration files such as remap config. Note that
- this applies only during startup of Traffic Server and does not apply to the run
- time heartbeat checking.
-
-.. ts:cv:: CONFIG proxy.config.cop.active_health_checks INT 3
-
- Specifies which, if any, of :program:`traffic_server` and
- :program:`traffic_manager` that :program:`traffic_cop` is allowed to kill
- in the event of failed health checks. The possible values are:
-
- ===== ======================================================================
- Value Description
- ===== ======================================================================
- ``0`` :program:`traffic_cop` is not allowed to kill any processes.
- ``1`` Only :program:`traffic_manager` can be killed on failed health checks.
- ``2`` Only :program:`traffic_server` can be killed on failed health checks.
- ``3`` :program:`traffic_server` and :program:`traffic_manager` can be killed
- on failures (default).
- ===== ======================================================================
.. ts:cv:: CONFIG proxy.config.output.logfile STRING traffic.out
@@ -614,10 +571,6 @@ Cluster
Local Manager
=============
-.. ts:cv:: CONFIG proxy.config.admin.synthetic_port INT 8083
-
- The synthetic healthcheck port.
-
.. ts:cv:: CONFIG proxy.config.admin.number_config_bak INT 3
The maximum number of copies of rolled configuration files to keep.
@@ -664,14 +617,6 @@ Local Manager
:program:`traffic_ctl config set`, but these changes will not be persisted
on service restarts or when :option:`traffic_ctl config reload` is run.
-Process Manager
-===============
-
-.. ts:cv:: CONFIG proxy.config.process_manager.mgmt_port INT 8084
-
- The port used for internal communication between :program:`traffic_manager`
- and :program:`traffic_server` processes.
-
Alarm Configuration
===================
@@ -1112,11 +1057,6 @@ ip-resolve
according to this setting then it will be used, otherwise it will be released to the pool and a different session
selected or created.
-.. ts:cv:: CONFIG proxy.config.http.record_heartbeat INT 0
- :reloadable:
-
- Enables (``1``) or disables (``0``) :program:`traffic_cop` heartbeat logging.
-
.. ts:cv:: CONFIG proxy.config.http.use_client_target_addr INT 0
For fully transparent ports use the same origin server address as the client.
diff --git a/doc/admin-guide/installation/index.en.rst b/doc/admin-guide/installation/index.en.rst
index 4ec3523..48cbd90 100644
--- a/doc/admin-guide/installation/index.en.rst
+++ b/doc/admin-guide/installation/index.en.rst
@@ -227,9 +227,8 @@ Stop Traffic Server
To stop Traffic Server, always use the :program:`trafficserver` command,
passing in the attribute ``stop``. This command stops all the Traffic
-Server processes (:program:`traffic_manager`, :program:`traffic_server`, and
-:program:`traffic_cop`). Do not manually stop processes, as this can lead to
-unpredictable results. ::
+Server processes (:program:`traffic_manager` and :program:`traffic_server`).
+Do not manually stop processes, as this can lead to unpredictable results. ::
bin/trafficserver stop
diff --git a/doc/admin-guide/introduction.en.rst b/doc/admin-guide/introduction.en.rst
index 43ad822..493c04e 100644
--- a/doc/admin-guide/introduction.en.rst
+++ b/doc/admin-guide/introduction.en.rst
@@ -193,22 +193,13 @@ requests and manage, control, and monitor the health of the system.
first-served order. This connection queueing shields users from any
server restart downtime.
-- The :program:`traffic_cop` process monitors the health of both the
- :program:`traffic_server` and :program:`traffic_manager` processes. The
- :program:`traffic_cop` process periodically (several times each minute)
- queries the :program:`traffic_server` and :program:`traffic_manager`
- processes by issuing heartbeat requests to fetch synthetic web pages. In the
- event of failure (if no response is received within a timeout interval or
- if an incorrect response is received), :program:`traffic_cop` restarts the
- :program:`traffic_manager` and :program:`traffic_server` processes.
-
-The figure below illustrates the three Traffic Server processes.
+The figure below illustrates the Traffic Server processes.
.. figure:: ../static/images/admin/process.jpg
:align: center
- :alt: Illustration of the three Traffic Server Processes
+ :alt: Illustration of the Traffic Server Processes
- Illustration of the three Traffic Server Processes
+ Illustration of the Traffic Server Processes
Administration Tools
--------------------
diff --git a/doc/admin-guide/logging/understanding.en.rst b/doc/admin-guide/logging/understanding.en.rst
index 387a6df..40c1ebd 100644
--- a/doc/admin-guide/logging/understanding.en.rst
+++ b/doc/admin-guide/logging/understanding.en.rst
@@ -84,8 +84,7 @@ specifies where these messages are logged. A typical location is
The :manpage:`syslog(8)` process works on a system-wide basis, so it serves as
the single repository for messages from all |TS| processes (including
-:program:`traffic_server`, :program:`traffic_manager`, and
-:program:`traffic_cop`).
+:program:`traffic_server` and :program:`traffic_manager`).
System information logs observe a static format. Each log entry in the log
contains information about the date and time the error was logged, the hostname
diff --git a/doc/appendices/command-line/traffic_cop.en.rst b/doc/appendices/command-line/traffic_cop.en.rst
deleted file mode 100644
index 5c78a4e..0000000
--- a/doc/appendices/command-line/traffic_cop.en.rst
+++ /dev/null
@@ -1,70 +0,0 @@
-.. Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
-.. include:: ../../common.defs
-
-.. _traffic_cop:
-
-traffic_cop
-***********
-
-Description
-===========
-
-:program:`traffic_cop` is a watchdog program that is responsible
-for starting :ref:`traffic_manager` and :ref:`traffic_server`
-and monitoring them for responsiveness. If either of these processes
-are determined to be unresponsive, :program:`traffic_cop` will kill
-and restart them.
-
-On Linux, :program:`traffic_cop` will also monitor available memory
-and swap space, restarting the watched processes if the available
-memory falls below a minimum threshold. The memory thresholds can
-be configured with the :ts:cv:`proxy.config.cop.linux_min_swapfree_kb`
-and :ts:cv:`proxy.config.cop.linux_min_memfree_kb` variables.
-
-Options
-=======
-
-.. program:: traffic_cop
-
-.. option:: -d, --debug
-
- Emit debugging messages.
-
-.. option:: -o, --stdout
-
- :program:`traffic_cop` ordinarily logs to syslog, however for
- debugging purposes, this option causes it to print messages to
- standard output instead.
-
-.. option:: -s, --stop
-
- Kill children using ``SIGSTOP`` instead of ``SIGKILL``. This
- option is primarily for debugging.
-
-.. option:: -V, --version
-
- Print version information and exit.
-
-See also
-========
-
-:manpage:`syslog(1)`,
-:manpage:`traffic_manager(8)`,
-:manpage:`traffic_server(8)`
-
diff --git a/doc/appendices/faq.en.rst b/doc/appendices/faq.en.rst
index 09bcbb6..be1908c 100644
--- a/doc/appendices/faq.en.rst
+++ b/doc/appendices/faq.en.rst
@@ -464,24 +464,6 @@ port. Traffic Server clusters should ideally be configured to use a
separate network interface and cluster on a private subnet, so that
client machines have no access to the cluster ports.
-'No cop file' message in the system log file
---------------------------------------------
-
-The following message appears repeatedly in the system log file: ::
-
- traffic_cop[16056]: encountered "var/trafficserver/no_cop" file...exiting
-
-The file ``var/trafficserver/no_cop`` acts as an administrative control
-that instructs the :program:`traffic_cop` process to exit immediately without
-starting :program:`traffic_manager` or performing any health checks. The
-``no_cop`` file prevents Traffic Server from starting automatically when
-it has been stopped with the option:`trafficserver stop` command. Without
-this static control, Traffic Server would restart automatically upon
-system reboot. The ``no_cop`` control keeps Traffic Server off until it
-is explicitly restarted with: ::
-
- trafficserver start
-
Warning in the system log file when manually editing vaddrs.config
------------------------------------------------------------------
diff --git a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst b/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
index 2babed1..53ce764 100644
--- a/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
+++ b/doc/developer-guide/api/types/TSRecordUpdateType.en.rst
@@ -47,10 +47,6 @@ Enumeration Members
The value is updated if the :program:`traffic_manager` process is restarted.
-.. c:member:: TSRecordUpdateType TS_RECORDUPDATE_RESTART_TC
-
- The value is updated if the :program:`traffic_cop` process is restarted. This is effect a complete restart of |TS|.
-
Description
===========
diff --git a/doc/developer-guide/config-vars.en.rst b/doc/developer-guide/config-vars.en.rst
index 54ec82f..d5d5998 100644
--- a/doc/developer-guide/config-vars.en.rst
+++ b/doc/developer-guide/config-vars.en.rst
@@ -132,9 +132,6 @@ update:``RecUpdateT``
``RECD_RESTART_TM``
The :program:`traffic_manager` process must be restarted for a new value to take effect.
- ``RECD_RESTART_TC``
- The :program:`traffic_cop` process must be restarted for a new value to take effect.
-
required:``RecordRequiredType``
Effectively a boolean that specifies if the record is required to be present,
with ``RR_NULL`` meaning not required and ``RR_REQUIRED`` indicating that it
diff --git a/doc/developer-guide/core-architecture/rpc.en.rst b/doc/developer-guide/core-architecture/rpc.en.rst
index 6d76349..3c46c84 100644
--- a/doc/developer-guide/core-architecture/rpc.en.rst
+++ b/doc/developer-guide/core-architecture/rpc.en.rst
@@ -53,7 +53,6 @@ Runtime Structure
node "traffic_server"
[traffic_ctl] <-d-> [traffic_manager] : Remote RPC
- [traffic_cop] <-r-> [traffic_manager] : Remote RPC
[other remote clients] <-u-> [traffic_manager] : Remote RPC
[traffic_manager] <-r-> [traffic_server] : Local RPC
[traffic_server] <-r-> [plugin] : Hook
@@ -76,7 +75,7 @@ Sequence diagram for a command sent from |TCtl| to when it is recieved by a plug
Remote RPC vs Local RPC
=======================
-The RPC API for remote clients, such as |TCtl|, :program:`traffic_cop`, etc, is different from the RPC API used between |TManager| and |TServer|.
+The RPC API for remote clients, such as |TCtl|, etc, is different from the RPC API used between |TManager| and |TServer|.
|TManager| acts like a bridge for remote clients to interact with |TServer|. Thus, it is currently impossible to do things like have |TCtl| directly send messages to |TServer|. Classes suffixed with "Remote", ie. :ts:git:`CoreAPIRemote.cc`, and classes suffixed with "Local", ie. :ts:git:`NetworkUtilsLocal.cc` are for remote and local clients, respectively. The following sections will note which set of RPC's are relevant.
diff --git a/doc/manpages.py b/doc/manpages.py
index d4982de..961fc8d 100644
--- a/doc/manpages.py
+++ b/doc/manpages.py
@@ -22,7 +22,6 @@ man_pages = [
# pages
('developer-guide/api/functions/' + filename[:-4], filename.split('.', 1)[0], filename.split('.', 1)[0] + ' API function', None, '3ts') for filename in os.listdir('developer-guide/api/functions/') if filename != 'index.en.rst' and filename.endswith('.rst')] + [
- ('appendices/command-line/traffic_cop.en', 'traffic_cop', u'Traffic Server watchdog', None, '8'),
('appendices/command-line/traffic_ctl.en', 'traffic_ctl', u'Traffic Server command line tool', None, '8'),
('appendices/command-line/traffic_crashlog.en', 'traffic_crashlog', u'Traffic Server crash log helper', None, '8'),
('appendices/command-line/traffic_logcat.en', 'traffic_logcat', u'Traffic Server log spooler', None, '8'),
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 8b01374..bed342b 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -107,7 +107,6 @@ enum RecUpdateT {
RECU_DYNAMIC, // config can be updated dynamically w/ "traffic_ctl config reload"
RECU_RESTART_TS, // config requires TS to be restarted to take effect
RECU_RESTART_TM, // config requires TM/TS to be restarted to take effect
- RECU_RESTART_TC // config requires TC/TM/TS to be restarted to take effect
};
enum RecCheckT {
diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc
index ef88e91..3c2a4f1 100644
--- a/lib/records/RecLocal.cc
+++ b/lib/records/RecLocal.cc
@@ -128,11 +128,6 @@ config_update_thr(void * /* data */)
RecSetRecordInt("proxy.node.config.restart_required.proxy", 1, REC_SOURCE_DEFAULT);
RecSetRecordInt("proxy.node.config.restart_required.manager", 1, REC_SOURCE_DEFAULT);
break;
- case RECU_RESTART_TC:
- RecSetRecordInt("proxy.node.config.restart_required.proxy", 1, REC_SOURCE_DEFAULT);
- RecSetRecordInt("proxy.node.config.restart_required.manager", 1, REC_SOURCE_DEFAULT);
- RecSetRecordInt("proxy.node.config.restart_required.cop", 1, REC_SOURCE_DEFAULT);
- break;
case RECU_NULL:
case RECU_DYNAMIC:
break;
diff --git a/lib/ts/BaseLogFile.cc b/lib/ts/BaseLogFile.cc
index bc3abca..2d130bf 100644
--- a/lib/ts/BaseLogFile.cc
+++ b/lib/ts/BaseLogFile.cc
@@ -378,7 +378,7 @@ BaseLogFile::display(FILE *fd)
* However, we still need to log the creation of BaseLogFile, since the
* information is still useful. This function will print out log messages
* into traffic.out if we happen to be bootstrapping Diags. Since
- * traffic_cop redirects stdout/stderr into traffic.out, that
+ * traffic_manager redirects stdout/stderr into traffic.out, that
* redirection is inherited by way of exec()/fork() all the way here.
*
* TODO use Debug() for non bootstrap instances
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index 6538f20..a228d68 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -627,7 +627,6 @@ typedef enum {
TS_RECORDUPDATE_DYNAMIC,
TS_RECORDUPDATE_RESTART_TS,
TS_RECORDUPDATE_RESTART_TM,
- TS_RECORDUPDATE_RESTART_TC
} TSRecordUpdateType;
/* The values of this enum must match enum RecCheckT in I_RecDefs.h */
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index d156f68..21559c5 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -60,14 +60,14 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.env_prep", RECD_STRING, nullptr, RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.config_dir", RECD_STRING, TS_BUILD_SYSCONFDIR, RECU_RESTART_TC, RR_NULL, RECC_NULL, nullptr, RECA_READ_ONLY}
+ {RECT_CONFIG, "proxy.config.config_dir", RECD_STRING, TS_BUILD_SYSCONFDIR, RECU_RESTART_TM, RR_NULL, RECC_NULL, nullptr, RECA_READ_ONLY}
,
// Jira TS-21
{RECT_CONFIG, "proxy.config.local_state_dir", RECD_STRING, TS_BUILD_RUNTIMEDIR, RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_READ_ONLY}
,
{RECT_CONFIG, "proxy.config.alarm_email", RECD_STRING, TS_PKGSYSUSER, RECU_DYNAMIC, RR_NULL, RECC_STR, ".*", RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.syslog_facility", RECD_STRING, "LOG_DAEMON", RECU_RESTART_TC, RR_NULL, RECC_STR, ".*", RECA_NULL}
+ {RECT_CONFIG, "proxy.config.syslog_facility", RECD_STRING, "LOG_DAEMON", RECU_RESTART_TM, RR_NULL, RECC_STR, ".*", RECA_NULL}
,
//# Negative core limit means max out limit
{RECT_CONFIG, "proxy.config.core_limit", RECD_INT, "-1", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
@@ -77,16 +77,6 @@ static const RecordElement RecordsConfig[] =
// 0 - Disabled, 1 - enabled for important pages (e.g. cache directory), 2 - enabled for all pages
{RECT_CONFIG, "proxy.config.mlock_enabled", RECD_INT, "0", RECU_RESTART_TS, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.cop.core_signal", RECD_INT, "0", RECU_DYNAMIC, RR_REQUIRED, RECC_NULL, nullptr, RECA_NULL}
- , // needed by traffic_cop
- {RECT_CONFIG, "proxy.config.cop.linux_min_swapfree_kb", RECD_INT, "0", RECU_DYNAMIC, RR_REQUIRED, RECC_NULL, nullptr, RECA_NULL}
- , // needed by traffic_cop
- {RECT_CONFIG, "proxy.config.cop.linux_min_memfree_kb", RECD_INT, "0", RECU_DYNAMIC, RR_REQUIRED, RECC_NULL, nullptr, RECA_NULL}
- , // needed by traffic_cop
- {RECT_CONFIG, "proxy.config.cop.init_sleep_time", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-900]", RECA_NULL}
- ,
- {RECT_CONFIG, "proxy.config.cop.active_health_checks", RECD_INT, "3", RECU_NULL, RR_NULL, RECC_NULL, "[0-3]", RECA_NULL}
- ,
//# 0 = disable (seconds)
{RECT_CONFIG, "proxy.config.dump_mem_info_frequency", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
@@ -95,7 +85,7 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.cache.max_disk_errors", RECD_INT, "5", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.output.logfile", RECD_STRING, "traffic.out", RECU_RESTART_TC, RR_REQUIRED, RECC_NULL, nullptr,
+ {RECT_CONFIG, "proxy.config.output.logfile", RECD_STRING, "traffic.out", RECU_RESTART_TM, RR_REQUIRED, RECC_NULL, nullptr,
RECA_NULL}
,
{RECT_CONFIG, "proxy.config.output.logfile_perm", RECD_STRING, "rw-r--r--", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
@@ -248,8 +238,6 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.lm.pserver_timeout_msecs", RECD_INT, "0", RECU_RESTART_TM, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.admin.synthetic_port", RECD_INT, "8083", RECU_RESTART_TM, RR_REQUIRED, RECC_INT, "[0-65535]", RECA_NULL}
- ,
{RECT_CONFIG, "proxy.config.admin.autoconf.localhost_only", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.admin.admin_user", RECD_STRING, "admin", RECU_DYNAMIC, RR_REQUIRED, RECC_STR, ".+", RECA_NO_ACCESS}
@@ -284,8 +272,6 @@ static const RecordElement RecordsConfig[] =
//##############################################################################
{RECT_CONFIG, "proxy.config.process_manager.timeout", RECD_INT, "5", RECU_NULL, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.process_manager.mgmt_port", RECD_INT, "8084", RECU_NULL, RR_REQUIRED, RECC_NULL, nullptr, RECA_NULL}
- ,
//##############################################################################
//#
@@ -385,8 +371,6 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.http.server_session_sharing.pool", RECD_STRING, "thread", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.http.record_heartbeat", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
- ,
{RECT_CONFIG, "proxy.config.http.default_buffer_size", RECD_INT, "8", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.default_buffer_water_mark", RECD_INT, "32768", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
@@ -778,7 +762,7 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.net.default_inactivity_timeout", RECD_INT, "86400", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.net.inactivity_check_frequency", RECD_INT, "1", RECU_RESTART_TC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
+ {RECT_CONFIG, "proxy.config.net.inactivity_check_frequency", RECD_INT, "1", RECU_RESTART_TM, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.net.event_period", RECD_INT, "10", RECU_RESTART_TS, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
,
diff --git a/mgmt/WebMgmtUtils.cc b/mgmt/WebMgmtUtils.cc
index d92b2ad..41bf759 100644
--- a/mgmt/WebMgmtUtils.cc
+++ b/mgmt/WebMgmtUtils.cc
@@ -1229,7 +1229,7 @@ recordRestartCheck(const char *varName)
return false;
}
- if (update_t == RECU_RESTART_TS || update_t == RECU_RESTART_TM || update_t == RECU_RESTART_TC) {
+ if (update_t == RECU_RESTART_TS || update_t == RECU_RESTART_TM) {
return true;
}
diff --git a/proxy/Main.cc b/proxy/Main.cc
index f6bc2b5..1c31fe1 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1972,14 +1972,6 @@ main(int /* argc ATS_UNUSED */, const char **argv)
} else {
start_HttpProxyServer(); // PORTS_READY_HOOK called from in here
}
-
- // Start the back door, since it's just a special HttpProxyServer,
- // the requirements to start it have been met if we got here.
- int back_door_port = NO_FD;
- REC_ReadConfigInteger(back_door_port, "proxy.config.process_manager.mgmt_port");
- if (back_door_port != NO_FD) {
- start_HttpProxyServerBackDoor(back_door_port, !!num_accept_threads); // One accept thread is enough
- }
}
SNIConfig::cloneProtoSet();
// Plugins can register their own configuration names so now after they've done that
diff --git a/proxy/ReverseProxy.cc b/proxy/ReverseProxy.cc
index f1220e1..6203dda 100644
--- a/proxy/ReverseProxy.cc
+++ b/proxy/ReverseProxy.cc
@@ -51,7 +51,6 @@ remap_plugin_info *remap_pi_list; // We never reload the remap plugins, just app
#define FILE_CHANGED 0
#define REVERSE_CHANGED 1
#define TSNAME_CHANGED 2
-#define SYNTH_PORT_CHANGED 3
#define TRANS_CHANGED 4
#define URL_REMAP_MODE_CHANGED 8
#define HTTP_DEFAULT_REDIRECT_CHANGED 9
@@ -74,7 +73,6 @@ init_reverse_proxy()
REC_RegisterConfigUpdateFunc("proxy.config.url_remap.filename", url_rewrite_CB, (void *)FILE_CHANGED);
REC_RegisterConfigUpdateFunc("proxy.config.proxy_name", url_rewrite_CB, (void *)TSNAME_CHANGED);
REC_RegisterConfigUpdateFunc("proxy.config.reverse_proxy.enabled", url_rewrite_CB, (void *)REVERSE_CHANGED);
- REC_RegisterConfigUpdateFunc("proxy.config.admin.synthetic_port", url_rewrite_CB, (void *)SYNTH_PORT_CHANGED);
REC_RegisterConfigUpdateFunc("proxy.config.http.referer_default_redirect", url_rewrite_CB, (void *)HTTP_DEFAULT_REDIRECT_CHANGED);
// Hold at least one lease, until we reload the configuration
@@ -170,10 +168,6 @@ url_rewrite_CB(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNU
eventProcessor.schedule_imm(new UR_UpdateContinuation(reconfig_mutex), ET_TASK);
break;
- case SYNTH_PORT_CHANGED:
- // The AutoConf port does not current change on manager except at restart
- break;
-
case URL_REMAP_MODE_CHANGED:
// You need to restart TS.
break;
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 65990ef..db9b443 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1129,8 +1129,6 @@ HttpConfig::startup()
HttpEstablishStaticConfigLongLong(c.oride.slow_log_threshold, "proxy.config.http.slow.log.threshold");
HttpEstablishStaticConfigByte(c.oride.ssl_client_verify_server, "proxy.config.ssl.client.verify.server");
- HttpEstablishStaticConfigByte(c.record_cop_page, "proxy.config.http.record_heartbeat");
-
HttpEstablishStaticConfigByte(c.oride.send_http11_requests, "proxy.config.http.send_http11_requests");
HttpEstablishStaticConfigByte(c.oride.allow_multi_range, "proxy.config.http.allow_multi_range");
@@ -1171,9 +1169,6 @@ HttpConfig::startup()
HttpEstablishStaticConfigLongLong(c.oride.number_of_redirections, "proxy.config.http.number_of_redirections");
HttpEstablishStaticConfigLongLong(c.post_copy_size, "proxy.config.http.post_copy_size");
- // Local Manager
- HttpEstablishStaticConfigLongLong(c.synthetic_port, "proxy.config.admin.synthetic_port");
-
http_config_cont->handleEvent(EVENT_NONE, nullptr);
return;
@@ -1404,7 +1399,6 @@ HttpConfig::reconfigure()
params->url_remap_required = INT_TO_BOOL(m_master.url_remap_required);
params->errors_log_error_pages = INT_TO_BOOL(m_master.errors_log_error_pages);
params->oride.slow_log_threshold = m_master.oride.slow_log_threshold;
- params->record_cop_page = INT_TO_BOOL(m_master.record_cop_page);
params->oride.ssl_client_verify_server = m_master.oride.ssl_client_verify_server;
params->oride.send_http11_requests = m_master.oride.send_http11_requests;
params->oride.doc_in_cache_skip_dns = INT_TO_BOOL(m_master.oride.doc_in_cache_skip_dns);
@@ -1439,9 +1433,6 @@ HttpConfig::reconfigure()
params->oride.client_cert_filename = ats_strdup(m_master.oride.client_cert_filename);
params->oride.client_cert_filepath = ats_strdup(m_master.oride.client_cert_filepath);
- // Local Manager
- params->synthetic_port = m_master.synthetic_port;
-
m_id = configProcessor.set(m_id, params);
#undef INT_TO_BOOL
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 8411fc6..2f156ff 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -815,11 +815,6 @@ public:
MgmtInt post_copy_size = 2048;
MgmtInt max_post_size = 0;
- ////////////////////
- // Local Manager //
- ////////////////////
- MgmtInt synthetic_port = 0;
-
///////////////////////////////////////////////////////////////////
// Put all MgmtByte members down here, avoids additional padding //
///////////////////////////////////////////////////////////////////
@@ -844,8 +839,6 @@ public:
MgmtByte reverse_proxy_enabled = 0;
MgmtByte url_remap_required = 1;
- MgmtByte record_cop_page = 0;
-
MgmtByte errors_log_error_pages = 1;
MgmtByte enable_http_info = 0;
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 77e93f7..95190a9 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -3950,10 +3950,7 @@ HttpSM::do_remap_request(bool run_inline)
{
SMDebug("http_seq", "[HttpSM::do_remap_request] Remapping request");
SMDebug("url_rewrite", "Starting a possible remapping for request [%" PRId64 "]", sm_id);
- bool ret = false;
- if (t_state.cop_test_page == false) {
- ret = remapProcessor.setup_for_remap(&t_state, m_remap);
- }
+ bool ret = remapProcessor.setup_for_remap(&t_state, m_remap);
// Preserve effective url before remap
t_state.unmapped_url.create(t_state.hdr_info.client_request.url_get()->m_heap);
@@ -5989,9 +5986,7 @@ HttpSM::setup_server_send_request()
t_state.hdr_info.server_request.value_set_int64(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH, msg_len);
}
- if (!t_state.cop_test_page) {
- DUMP_HEADER("http_hdrs", &(t_state.hdr_info.server_request), t_state.state_machine_id, "Proxy's Request after hooks");
- }
+ DUMP_HEADER("http_hdrs", &(t_state.hdr_info.server_request), t_state.state_machine_id, "Proxy's Request after hooks");
// We need a reader so bytes don't fall off the end of
// the buffer
@@ -6876,22 +6871,20 @@ HttpSM::kill_this()
HTTP_SM_SET_DEFAULT_HANDLER(nullptr);
- if (!t_state.cop_test_page || t_state.http_config_param->record_cop_page) {
- //////////////
- // Log Data //
- //////////////
- SMDebug("http_seq", "[HttpSM::update_stats] Logging transaction");
- if (Log::transaction_logging_enabled() && t_state.api_info.logging_enabled) {
- LogAccessHttp accessor(this);
+ //////////////
+ // Log Data //
+ //////////////
+ SMDebug("http_seq", "[HttpSM::update_stats] Logging transaction");
+ if (Log::transaction_logging_enabled() && t_state.api_info.logging_enabled) {
+ LogAccessHttp accessor(this);
- int ret = Log::access(&accessor);
+ int ret = Log::access(&accessor);
- if (ret & Log::FULL) {
- SMDebug("http", "[update_stats] Logging system indicates FULL.");
- }
- if (ret & Log::FAIL) {
- Log::error("failed to log transaction for at least one log object");
- }
+ if (ret & Log::FULL) {
+ SMDebug("http", "[update_stats] Logging system indicates FULL.");
+ }
+ if (ret & Log::FAIL) {
+ Log::error("failed to log transaction for at least one log object");
}
}
@@ -6919,11 +6912,6 @@ HttpSM::update_stats()
{
milestones[TS_MILESTONE_SM_FINISH] = Thread::get_hrtime();
- if (t_state.cop_test_page && !t_state.http_config_param->record_cop_page) {
- SMDebug("http_seq", "Skipping cop heartbeat logging & stats due to config");
- return;
- }
-
if (is_action_tag_set("bad_length_state_dump")) {
if (t_state.hdr_info.client_response.valid() && t_state.hdr_info.client_response.status_get() == HTTP_STATUS_OK) {
int64_t p_resp_cl = t_state.hdr_info.client_response.get_content_length();
@@ -7289,13 +7277,6 @@ HttpSM::set_next_state()
break;
} else if (t_state.dns_info.looking_up == HttpTransact::ORIGIN_SERVER && t_state.http_config_param->no_dns_forward_to_parent &&
t_state.parent_result.result != PARENT_UNDEFINED) {
- if (t_state.cop_test_page) {
- NetVConnection *vc = t_state.state_machine->ua_txn->get_netvc();
- if (vc) {
- ats_ip_copy(t_state.host_db_info.ip(), vc->get_local_addr());
- }
- }
-
t_state.dns_info.lookup_success = true;
call_transact_and_set_next_state(nullptr);
break;
@@ -7894,9 +7875,7 @@ HttpSM::redirect_request(const char *redirect_url, const int redirect_len)
}
}
- if (!t_state.cop_test_page) {
- DUMP_HEADER("http_hdrs", &t_state.hdr_info.client_request, sm_id, "Framed Client Request..checking");
- }
+ DUMP_HEADER("http_hdrs", &t_state.hdr_info.client_request, sm_id, "Framed Client Request..checking");
}
void
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 406e9e8..dcbc551 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -608,26 +608,6 @@ HttpTransact::StartRemapRequest(State *s)
TxnDebug("http_trans", "START HttpTransact::StartRemapRequest");
- /**
- * Check for URL remappings before checking request
- * validity or initializing state variables since
- * the remappings can insert or change the destination
- * host, port and protocol.
- **/
-
- HTTPHdr *incoming_request = &s->hdr_info.client_request;
- URL *url = incoming_request->url_get();
- int host_len, path_len;
- const char *host = url->host_get(&host_len);
- const char *path = url->path_get(&path_len);
- const int port = url->port_get();
-
- const char syntxt[] = "synthetic.txt";
-
- s->cop_test_page = is_localhost(host, host_len) && ((path_len == sizeof(syntxt) - 1) && (memcmp(path, syntxt, path_len) == 0)) &&
- port == s->http_config_param->synthetic_port && s->method == HTTP_WKSIDX_GET &&
- s->orig_scheme == URL_WKSIDX_HTTP && ats_ip4_addr_cast(&s->client_info.dst_addr.sa) == htonl(INADDR_LOOPBACK);
-
//////////////////////////////////////////////////////////////////
// FIX: this logic seems awfully convoluted and hard to follow; //
// seems like we could come up with a more elegant and //
@@ -788,13 +768,11 @@ HttpTransact::EndRemapRequest(State *s)
}
s->reverse_proxy = false;
goto done;
- } else if (s->http_config_param->url_remap_required && !s->cop_test_page) {
+ } else if (s->http_config_param->url_remap_required) {
///////////////////////////////////////////////////////
// the url mapping failed, but mappings are strictly //
- // required (except for synthetic cop accesses), so //
- // return an error message. //
+ // required so return an error message. //
///////////////////////////////////////////////////////
-
SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
build_error_response(s, HTTP_STATUS_NOT_FOUND, "Not Found", "urlrouting#no_mapping");
s->squid_codes.log_code = SQUID_LOG_ERR_INVALID_URL;
@@ -1225,8 +1203,7 @@ HttpTransact::HandleRequest(State *s)
// this needs to be called after initializing state variables from request
// it adds the client-ip to the incoming client request.
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.client_request, s->state_machine_id, "Incoming Request");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.client_request, s->state_machine_id, "Incoming Request");
if (s->state_machine->plugin_tunnel_type == HTTP_PLUGIN_AS_INTERCEPT) {
setup_plugin_request_intercept(s);
@@ -1235,13 +1212,9 @@ HttpTransact::HandleRequest(State *s)
// if ip in url or cop test page, not do srv lookup.
if (s->txn_conf->srv_enabled) {
- if (s->cop_test_page) {
- s->txn_conf->srv_enabled = false;
- } else {
- IpEndpoint addr;
- ats_ip_pton(s->server_info.name, &addr);
- s->txn_conf->srv_enabled = !ats_is_ip(&addr);
- }
+ IpEndpoint addr;
+ ats_ip_pton(s->server_info.name, &addr);
+ s->txn_conf->srv_enabled = !ats_is_ip(&addr);
}
// if the request is a trace or options request, decrement the
@@ -1827,7 +1800,7 @@ void
HttpTransact::DecideCacheLookup(State *s)
{
// Check if a client request is lookupable.
- if (s->redirect_info.redirect_in_process || s->cop_test_page) {
+ if (s->redirect_info.redirect_in_process) {
// for redirect, we want to skip cache lookup and write into
// the cache directly with the URL before the redirect
s->cache_info.action = CACHE_DO_NO_ACTION;
@@ -2001,11 +1974,9 @@ HttpTransact::HandlePushResponseHdr(State *s)
s->hdr_info.server_request.method_set(HTTP_METHOD_GET, HTTP_LEN_GET);
s->hdr_info.server_request.value_set("X-Inktomi-Source", 16, "http PUSH", 9);
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id, "Pushed Response Header");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id, "Pushed Response Header");
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Generated Request Header");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Generated Request Header");
s->response_received_time = s->request_sent_time = ink_local_time();
@@ -2186,9 +2157,7 @@ HttpTransact::issue_revalidate(State *s)
// the client has the right credentials
// this cache action is just to get us into the hcoofsr function
s->cache_info.action = CACHE_DO_UPDATE;
- if (!s->cop_test_page) {
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
- }
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
return;
}
@@ -2262,8 +2231,7 @@ HttpTransact::issue_revalidate(State *s)
if (str) {
s->hdr_info.server_request.value_set(MIME_FIELD_IF_MODIFIED_SINCE, MIME_LEN_IF_MODIFIED_SINCE, str, length);
}
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
}
// if Etag exists, also add if-non-match header
if (c_resp->presence(MIME_PRESENCE_ETAG) && (s->hdr_info.server_request.method_get_wksidx() == HTTP_WKSIDX_GET ||
@@ -2277,8 +2245,7 @@ HttpTransact::issue_revalidate(State *s)
}
s->hdr_info.server_request.value_set(MIME_FIELD_IF_NONE_MATCH, MIME_LEN_IF_NONE_MATCH, etag, length);
}
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_request, s->state_machine_id, "Proxy's Request (Conditionalized)");
}
break;
case HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: // 203
@@ -3166,8 +3133,7 @@ HttpTransact::HandleResponse(State *s)
s->current.now = s->response_received_time;
TxnDebug("http_trans", "[HandleResponse] response_received_time: %" PRId64, (int64_t)s->response_received_time);
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id, "Incoming O.S. Response");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.server_response, s->state_machine_id, "Incoming O.S. Response");
HTTP_INCREMENT_DYN_STAT(http_incoming_responses_stat);
@@ -3907,8 +3873,7 @@ HttpTransact::build_response_copy(State *s, HTTPHdr *base_response, HTTPHdr *out
HttpTransactHeaders::convert_response(outgoing_version, outgoing_response); // http version conversion
HttpTransactHeaders::add_server_header_to_response(s->txn_conf, outgoing_response);
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", outgoing_response, s->state_machine_id, "Proxy's Response");
+ DUMP_HEADER("http_hdrs", outgoing_response, s->state_machine_id, "Proxy's Response");
}
//////////////////////////////////////////////////////////////////////////
@@ -4391,8 +4356,7 @@ HttpTransact::handle_cache_operation_on_forward_server_response(State *s)
warn_text, strlen(warn_text));
}
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.client_response, s->state_machine_id, "Proxy's Response (Client Conditionals)");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.client_response, s->state_machine_id, "Proxy's Response (Client Conditionals)");
return;
}
// all other responses (not 304, 412, 416) are handled here
@@ -4615,8 +4579,7 @@ HttpTransact::handle_transform_ready(State *s)
s->pre_transform_source = s->source;
s->source = SOURCE_TRANSFORM;
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.transform_response, s->state_machine_id, "Header From Transform");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.transform_response, s->state_machine_id, "Header From Transform");
build_response(s, &s->hdr_info.transform_response, &s->hdr_info.client_response, s->client_info.http_version);
@@ -4664,8 +4627,7 @@ HttpTransact::set_header_for_transform(State *s, HTTPHdr *base_header)
// in the chain
s->hdr_info.transform_response.field_delete(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", &s->hdr_info.transform_response, s->state_machine_id, "Header To Transform");
+ DUMP_HEADER("http_hdrs", &s->hdr_info.transform_response, s->state_machine_id, "Header To Transform");
}
void
@@ -4731,8 +4693,7 @@ HttpTransact::set_headers_for_cache_write(State *s, HTTPInfo *cache_info, HTTPHd
// add one marker to the content in cache
// cache_info->response_get()->value_set("@WWW-Auth", 9, "true", 4);
//}
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", cache_info->request_get(), s->state_machine_id, "Cached Request Hdr");
+ DUMP_HEADER("http_hdrs", cache_info->request_get(), s->state_machine_id, "Cached Request Hdr");
}
void
@@ -5604,10 +5565,8 @@ HttpTransact::initialize_state_variables_from_response(State *s, HTTPHdr *incomi
}
if (s->current.server->keep_alive == HTTP_KEEPALIVE) {
- if (!s->cop_test_page) {
- TxnDebug("http_hdrs", "[initialize_state_variables_from_response]"
- "Server is keep-alive.");
- }
+ TxnDebug("http_hdrs", "[initialize_state_variables_from_response]"
+ "Server is keep-alive.");
} else if (s->state_machine->ua_txn && s->state_machine->ua_txn->is_outbound_transparent() &&
s->state_machine->t_state.http_config_param->use_client_source_port) {
/* If we are reusing the client<->ATS 4-tuple for ATS<->server then if the server side is closed, we can't
@@ -5646,9 +5605,7 @@ HttpTransact::initialize_state_variables_from_response(State *s, HTTPHdr *incomi
const char *wks_value = hdrtoken_string_to_wks(enc_value, enc_val_len);
if (wks_value == HTTP_VALUE_CHUNKED && !is_response_body_precluded(status_code, s->method)) {
- if (!s->cop_test_page) {
- TxnDebug("http_hdrs", "[init_state_vars_from_resp] transfer encoding: chunked!");
- }
+ TxnDebug("http_hdrs", "[init_state_vars_from_resp] transfer encoding: chunked!");
s->current.server->transfer_encoding = CHUNKED_ENCODING;
s->hdr_info.response_content_length = HTTP_UNDEFINED_CL;
@@ -7649,8 +7606,7 @@ HttpTransact::build_request(State *s, HTTPHdr *base_request, HTTPHdr *outgoing_r
ink_assert(s->request_sent_time >= s->response_received_time);
TxnDebug("http_trans", "[build_request] request_sent_time: %" PRId64, (int64_t)s->request_sent_time);
- if (!s->cop_test_page)
- DUMP_HEADER("http_hdrs", outgoing_request, s->state_machine_id, "Proxy's Request");
+ DUMP_HEADER("http_hdrs", outgoing_request, s->state_machine_id, "Proxy's Request");
HTTP_INCREMENT_DYN_STAT(http_outgoing_requests_stat);
}
@@ -7793,7 +7749,7 @@ HttpTransact::build_response(State *s, HTTPHdr *base_response, HTTPHdr *outgoing
HttpTransactHeaders::add_connection_close(outgoing_response);
}
- if (!s->cop_test_page && is_debug_tag_set("http_hdrs")) {
+ if (is_debug_tag_set("http_hdrs")) {
if (base_response) {
DUMP_HEADER("http_hdrs", base_response, s->state_machine_id, "Base Header for Building Response");
}
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index 4eb46af..72b6946 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -735,7 +735,6 @@ public:
bool first_dns_lookup = true;
bool backdoor_request = false; // internal
- bool cop_test_page = false; // internal
HttpRequestData request_data;
ParentConfigParams *parent_params = nullptr;
ParentResult parent_result;
diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc
index cc0a47f..d95063c 100644
--- a/proxy/http/remap/UrlRewrite.cc
+++ b/proxy/http/remap/UrlRewrite.cc
@@ -56,7 +56,6 @@ SetHomePageRedirectFlag(url_mapping *new_mapping, URL &new_to_url)
UrlRewrite::UrlRewrite()
: nohost_rules(0),
reverse_proxy(0),
- mgmt_synthetic_port(0),
ts_name(nullptr),
http_default_redirect_url(nullptr),
num_rules_forward(0),
@@ -95,7 +94,6 @@ UrlRewrite::UrlRewrite()
}
REC_ReadConfigInteger(reverse_proxy, "proxy.config.reverse_proxy.enabled");
- REC_ReadConfigInteger(mgmt_synthetic_port, "proxy.config.admin.synthetic_port");
if (0 == this->BuildTable(config_file_path)) {
_valid = true;
diff --git a/proxy/http/remap/UrlRewrite.h b/proxy/http/remap/UrlRewrite.h
index 8421f43..4355ee6 100644
--- a/proxy/http/remap/UrlRewrite.h
+++ b/proxy/http/remap/UrlRewrite.h
@@ -181,9 +181,6 @@ public:
int nohost_rules;
int reverse_proxy;
- // Vars for synthetic health checks
- int mgmt_synthetic_port;
-
char *ts_name; // Used to send redirects when no host info
char *http_default_redirect_url; // Used if redirect in "referer" filtering was not defined properly
diff --git a/rc/trafficserver.conf.in b/rc/trafficserver.conf.in
index 3eb6671..487e73f 100644
--- a/rc/trafficserver.conf.in
+++ b/rc/trafficserver.conf.in
@@ -38,4 +38,4 @@ pre-start script
fi
end script
-exec @exp_bindir@/traffic_cop
+exec @exp_bindir@/traffic_manager
diff --git a/rc/trafficserver.in b/rc/trafficserver.in
index 9ca4c37..0c04e03 100644
--- a/rc/trafficserver.in
+++ b/rc/trafficserver.in
@@ -18,7 +18,7 @@
# chkconfig: - 90 10
# description: Apache Traffic Server is a fast, scalable and extensible \
# HTTP/1.1 compliant caching proxy server.
-# processname: traffic_cop traffic_manager traffic_server
+# processname: traffic_manager traffic_server
# config: /etc/trafficserver
# config: /etc/sysconfig/trafficserver
# pidfile: /var/run/trafficserver/cop.pid
@@ -102,17 +102,13 @@ TS_ROOT=${TS_ROOT:-$TS_PREFIX}
# For standard installations TS_BASE will be empty
eval TS_BASE="`echo $TS_ROOT | ${ESED} -e 's;@prefix@$;;'`"
-TC_NAME=${TC_NAME:-traffic_cop}
TM_NAME=${TM_NAME:-traffic_manager}
TS_NAME=${TS_NAME:-traffic_server}
-TC_DAEMON=${TC_DAEMON:-$TS_BASE@exp_bindir@/traffic_cop}
-TC_DAEMON_ARGS=""
TM_DAEMON=${TM_DAEMON:-$TS_BASE@exp_bindir@/traffic_manager}
TM_DAEMON_ARGS=""
TS_DAEMON=${TS_DAEMON:-$TS_BASE@exp_bindir@/traffic_server}
TS_DAEMON_ARGS=""
TL_BINARY=${TL_BINARY:-$TS_BASE@exp_bindir@/traffic_ctl}
-TC_PIDFILE=${TC_PIDFILE:-$TS_BASE@exp_runtimedir@/cop.lock}
TM_PIDFILE=${TM_PIDFILE:-$TS_BASE@exp_runtimedir@/manager.lock}
TS_PIDFILE=${TS_PIDFILE:-$TS_BASE@exp_runtimedir@/server.lock}
# number of times to retry check on pid lock file
@@ -196,7 +192,7 @@ forkdaemon()
while (( $i < $PIDFILE_CHECK_RETRIES ))
do
# check for regular file and size greater than 0
- if [[ -f $TC_PIDFILE ]] && [[ -s $TC_PIDFILE ]]
+ if [[ -f $TM_PIDFILE ]] && [[ -s $TM_PIDFILE ]]
then
success
return 0
@@ -221,16 +217,16 @@ do_start()
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON --test > /dev/null \
+ start-stop-daemon --start --quiet --pidfile $TM_PIDFILE --exec $TM_DAEMON --test > /dev/null \
|| return 1
- start-stop-daemon --start --background --quiet --pidfile $TC_PIDFILE --exec $TC_DAEMON -- \
- $TC_DAEMON_ARGS \
+ start-stop-daemon --start --background --quiet --pidfile $TM_PIDFILE --exec $TM_DAEMON -- \
+ $TM_DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
sleep 1
- test -f "$TC_PIDFILE" || return 2
+ test -f "$TM_PIDFILE" || return 2
}
#
@@ -243,7 +239,7 @@ do_stop()
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
- start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TC_PIDFILE --name $TC_NAME
+ start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $TM_PIDFILE --name $TM_NAME
RETVAL="$?"
test "$RETVAL" != 0 && return $RETVAL
# Wait for children to finish too if this is a daemon that forks
@@ -252,7 +248,7 @@ do_stop()
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TC_DAEMON
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $TM_DAEMON
RETVAL="$?"
test "$RETVAL" != 0 && return $RETVAL
# Need to stop the TM and TS also
@@ -263,7 +259,7 @@ do_stop()
RETVAL="$?"
test "$RETVAL" != 0 && return $RETVAL
# Many daemons don't delete their pidfiles when they exit.
- rm -f $TC_PIDFILE
+ rm -f $TM_PIDFILE
rm -f $TM_PIDFILE
rm -f $TS_PIDFILE
return "$RETVAL"
@@ -284,21 +280,21 @@ case "$1" in
do_start
eend $?
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
- action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TC_DAEMON $TC_DAEMON_ARGS
+ action "Starting ${TS_PACKAGE_NAME}:" forkdaemon $TM_DAEMON $TM_DAEMON_ARGS
elif [ "$DISTRIB_ID" = "suse" ]; then
echo -n "Starting ${TS_PACKAGE_NAME}"
- startproc -p $TC_PIDFILE $TC_DAEMON $TC_DAEMON_ARGS
+ startproc -p $TM_PIDFILE $TM_DAEMON $TM_DAEMON_ARGS
rc_status -v
elif [ "$DISTRIB_ID" = "Darwin" ]; then
echo "Starting ${TS_PACKAGE_NAME}"
- launchctl bsexec / launchctl list $TC_NAME > /dev/null 2>&1 && exit 0
- launchctl bsexec / launchctl submit -l $TC_NAME -p $TC_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TC_DAEMON_ARGS
+ launchctl bsexec / launchctl list $TM_NAME > /dev/null 2>&1 && exit 0
+ launchctl bsexec / launchctl submit -l $TM_NAME -p $TM_DAEMON -o $STDOUTLOG -e $STDERRLOG -- $TM_DAEMON_ARGS
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
echo "Starting ${TS_PACKAGE_NAME}"
- name="$TC_NAME"
+ name="$TM_NAME"
command="/usr/sbin/daemon"
- command_args="$TC_DAEMON $TC_DAEMON_ARGS"
- pidfile="$TC_PIDFILE"
+ command_args="$TM_DAEMON $TM_DAEMON_ARGS"
+ pidfile="$TM_PIDFILE"
run_rc_command "$1"
else
echo "This script needs to be ported to this OS"
@@ -314,7 +310,6 @@ case "$1" in
test "x$VERBOSE" != "xno" && log_end_msg "$retval"
exit "$retval"
elif [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
- action "Stopping ${TC_NAME}:" killproc -p $TC_PIDFILE -d 35 $TC_DAEMON
action "Stopping ${TM_NAME}:" killproc -p $TM_PIDFILE -d 35 $TM_DAEMON
action "Stopping ${TS_NAME}:" killproc -p $TS_PIDFILE -d 35 $TS_DAEMON
elif [ "$DISTRIB_ID" = "gentoo" ]; then
@@ -322,9 +317,6 @@ case "$1" in
do_stop
eend $?
elif [ "$DISTRIB_ID" = "suse" ]; then
- echo -n "Stopping ${TC_NAME}"
- killproc -p $TC_PIDFILE $TC_DAEMON
- rc_status -v
echo -n "Stopping ${TM_NAME}"
killproc -p $TM_PIDFILE $TM_DAEMON
rc_status -v
@@ -333,22 +325,15 @@ case "$1" in
rc_status -v
elif [ "$DISTRIB_ID" = "Darwin" ]; then
echo "Stopping ${TS_PACKAGE_NAME}"
- launchctl bsexec / launchctl list $TC_NAME > /dev/null 2>&1 || exit 0
- echo "Stopping ${TC_NAME}"
- launchctl bsexec / launchctl remove ${TC_NAME}
- rm -f ${TC_PIDFILE}
+ launchctl bsexec / launchctl list $TM_NAME > /dev/null 2>&1 || exit 0
echo "Stopping ${TM_NAME}"
- kill $(cat $TM_PIDFILE)
+ launchctl bsexec / launchctl remove ${TM_NAME}
rm -f ${TM_PIDFILE}
echo "Stopping ${TS_NAME}"
kill $(cat $TS_PIDFILE)
rm -f ${TS_PIDFILE}
elif [ "$DISTRIB_ID" = "FreeBSD" ]; then
echo "Stopping ${TS_PACKAGE_NAME}"
- if [ -e "$TC_PIDFILE" ]; then
- kill $(cat $TC_PIDFILE)
- rm -f ${TC_PIDFILE}
- fi
if [ -e "$TM_PIDFILE" ]; then
kill $(cat $TM_PIDFILE)
rm -f ${TM_PIDFILE}
@@ -419,16 +404,16 @@ case "$1" in
;;
status)
if [ "$DISTRIB_ID" = "fedora" -o "$DISTRIB_ID" = "redhat" ]; then
- status -p $TC_PIDFILE $TC_NAME
+ status -p $TM_PIDFILE $TM_NAME
elif [ "$DISTRIB_ID" = "ubuntu" -o "$DISTRIB_ID" = "debian" ] ; then
- status_of_proc "$TC_DAEMON" "$TC_NAME" -p "$TC_PIDFILE" && exit 0 || exit $?
+ status_of_proc "$TM_DAEMON" "$TM_NAME" -p "$TM_PIDFILE" && exit 0 || exit $?
elif [ "$DISTRIB_ID" = "suse" ]; then
echo -n "Checking for service ${DM}: "
- checkproc -p $TC_PIDFILE $TC_NAME
+ checkproc -p $TM_PIDFILE $TM_NAME
rc_status -v
elif [ "$DISTRIB_ID" = "Darwin" ]; then
/bin/echo -n "${TS_PACKAGE_NAME} is "
- launchctl bsexec / launchctl list $TC_NAME > /dev/null 2>&1
+ launchctl bsexec / launchctl list $TM_NAME > /dev/null 2>&1
status=$?
[ $status -eq 0 ] || /bin/echo -n "not "
echo "running."
@@ -441,10 +426,6 @@ case "$1" in
echo "$TS_NAME running as pid `cat $TS_PIDFILE`"; else
echo "$TS_NAME not running"
fi
- if pgrep $TC_NAME > /dev/null ; then
- echo "$TC_NAME running as pid `cat $TC_PIDFILE`"; else
- echo "$TC_NAME not running" ;
- fi
exit $status
else
echo "This script needs to be ported to this OS"
diff --git a/rc/trafficserver.service.in b/rc/trafficserver.service.in
index d200111..2bcdcb1 100644
--- a/rc/trafficserver.service.in
+++ b/rc/trafficserver.service.in
@@ -23,7 +23,7 @@ After=syslog.target network.target
Type=simple
EnvironmentFile=-/etc/sysconfig/trafficserver
PIDFile=@exp_runtimedir@/cop.pid
-ExecStart=@exp_bindir@/traffic_cop $TC_DAEMON_ARGS
+ExecStart=@exp_bindir@/traffic_manager $TC_DAEMON_ARGS
ExecReload=@exp_bindir@/traffic_ctl config reload
[Install]
diff --git a/rc/trafficserver.xml.in b/rc/trafficserver.xml.in
index c2fd5bb..5df3678 100644
--- a/rc/trafficserver.xml.in
+++ b/rc/trafficserver.xml.in
@@ -63,7 +63,7 @@
<exec_method
type='method'
name='start'
- exec='@exp_bindir@/traffic_cop 2>&1 &'
+ exec='@exp_bindir@/traffic_manager 2>&1 &'
timeout_seconds='120' />
<exec_method
diff --git a/tests/gold_tests/basic/basic-cop.test.py b/tests/gold_tests/basic/basic-cop.test.py
deleted file mode 100644
index 0d52031..0000000
--- a/tests/gold_tests/basic/basic-cop.test.py
+++ /dev/null
@@ -1,32 +0,0 @@
-'''
-'''
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-Test.Summary = '''
-Test that Trafficserver starts with default configurations.
-'''
-
-Test.SkipUnless(Condition.HasProgram("curl", "Curl need to be installed on system for this test to work"))
-
-p = Test.MakeATSProcess("ts", command="traffic_cop --debug --stdout", select_ports=False)
-t = Test.AddTestRun("Test traffic server started properly")
-t.StillRunningAfter = Test.Processes.ts
-
-p = t.Processes.Default
-p.Command = "curl http://127.0.0.1:8080"
-p.ReturnCode = 0
-p.StartBefore(Test.Processes.ts, ready=When.PortOpen(8080))
--
To stop receiving notification emails like this one, please contact
shinrich@apache.org.