You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/07/08 02:45:49 UTC

trafficserver git commit: TS-3575 Add support to show the ink_config.h features the system was compiled with

Repository: trafficserver
Updated Branches:
  refs/heads/master f6b5c389f -> b3ec3c568


TS-3575 Add support to show the ink_config.h features the system was compiled with


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

Branch: refs/heads/master
Commit: b3ec3c5684d8efa4113546112464139fd8cfd5d9
Parents: f6b5c38
Author: Leif Hedstrom <zw...@apache.org>
Authored: Tue Jul 7 18:42:19 2015 -0600
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Tue Jul 7 18:42:22 2015 -0600

----------------------------------------------------------------------
 cmd/traffic_layout/traffic_layout.cc | 157 +++++++++++++++++++++++++-----
 iocore/hostdb/HostDB.cc              |   1 -
 lib/ts/ink_config.h.in               |  10 +-
 proxy/hdrs/MIME.h                    |   1 -
 4 files changed, 138 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b3ec3c56/cmd/traffic_layout/traffic_layout.cc
----------------------------------------------------------------------
diff --git a/cmd/traffic_layout/traffic_layout.cc b/cmd/traffic_layout/traffic_layout.cc
index 331ded0..72d92c6 100644
--- a/cmd/traffic_layout/traffic_layout.cc
+++ b/cmd/traffic_layout/traffic_layout.cc
@@ -23,20 +23,145 @@
 
 #include "libts.h"
 #include "ink_args.h"
+#include "ink_config.h"
 #include "I_Version.h"
 #include "I_Layout.h"
 #include "I_RecProcess.h"
 #include "RecordsConfig.h"
 
-const ArgumentDescription argument_descriptions[] = {HELP_ARGUMENT_DESCRIPTION(), VERSION_ARGUMENT_DESCRIPTION()};
+// Command line arguments (parsing)
+struct CommandLineArgs {
+  int layout;
+  int features;
+  int json;
+};
+
+static CommandLineArgs cl;
+
+const ArgumentDescription argument_descriptions[] = {
+  {"layout", 'l', "Show the layout (this is the default with no options given)", "T", &cl.layout, NULL, NULL},
+  {"features", 'f', "Show the compiled features", "T", &cl.features, NULL, NULL},
+  {"json", 'j', "Produce output in JSON format (when supported)", "T", &cl.json, NULL, NULL},
+
+  HELP_ARGUMENT_DESCRIPTION(),
+  VERSION_ARGUMENT_DESCRIPTION()};
+
+
+// Produce output about compile time features, useful for checking how things were built, as well
+// as for our TSQA test harness.
+static void
+print_feature(const char *name, int value, bool json, bool last = false)
+{
+  if (json) {
+    printf("    \"%s\": %d%s", name, value, last ? "\n" : ",\n");
+  } else {
+    printf("#define %s %d\n", name, value);
+  }
+}
+
+static void
+print_feature(const char *name, const char *value, bool json, bool last = false)
+{
+  if (json) {
+    printf("    \"%s\": \"%s\"%s", name, value, last ? "\n" : ",\n");
+  } else {
+    printf("#define %s \"%s\"\n", name, value);
+  }
+}
+
+static void
+produce_features(bool json)
+{
+  if (json) {
+    printf("{\n");
+  }
+  print_feature("BUILD_MACHINE", BUILD_MACHINE, json);
+  print_feature("BUILD_PERSON", BUILD_PERSON, json);
+  print_feature("BUILD_GROUP", BUILD_GROUP, json);
+  print_feature("BUILD_NUMBER", BUILD_NUMBER, json);
+  print_feature("TS_HAS_LIBZ", TS_HAS_LIBZ, json);
+  print_feature("TS_HAS_LZMA", TS_HAS_LZMA, json);
+  print_feature("TS_HAS_JEMALLOC", TS_HAS_JEMALLOC, json);
+  print_feature("TS_HAS_TCMALLOC", TS_HAS_TCMALLOC, json);
+  print_feature("TS_HAS_IN6_IS_ADDR_UNSPECIFIED", TS_HAS_IN6_IS_ADDR_UNSPECIFIED, json);
+  print_feature("TS_HAS_BACKTRACE", TS_HAS_BACKTRACE, json);
+  print_feature("TS_HAS_PROFILER", TS_HAS_PROFILER, json);
+  print_feature("TS_USE_FAST_SDK", TS_USE_FAST_SDK, json);
+  print_feature("TS_USE_DIAGS", TS_USE_DIAGS, json);
+  print_feature("TS_USE_EPOLL", TS_USE_EPOLL, json);
+  print_feature("TS_USE_KQUEUE", TS_USE_KQUEUE, json);
+  print_feature("TS_USE_PORT", TS_USE_PORT, json);
+  print_feature("TS_USE_POSIX_CAP", TS_USE_POSIX_CAP, json);
+  print_feature("TS_USE_TPROXY", TS_USE_TPROXY, json);
+  print_feature("TS_HAS_SO_MARK", TS_HAS_SO_MARK, json);
+  print_feature("TS_HAS_SPDY", TS_HAS_SPDY, json);
+  print_feature("TS_HAS_IP_TOS", TS_HAS_IP_TOS, json);
+  print_feature("TS_USE_HWLOC", TS_USE_HWLOC, json);
+  print_feature("TS_USE_FREELIST", TS_USE_FREELIST, json);
+  print_feature("TS_USE_TLS_NPN", TS_USE_TLS_NPN, json);
+  print_feature("TS_USE_TLS_ALPN", TS_USE_TLS_ALPN, json);
+  print_feature("TS_USE_TLS_SNI", TS_USE_TLS_SNI, json);
+  print_feature("TS_USE_CERT_CB", TS_USE_CERT_CB, json);
+  print_feature("TS_USE_SET_RBIO", TS_USE_SET_RBIO, json);
+  print_feature("TS_USE_TLS_ECKEY", TS_USE_TLS_ECKEY, json);
+  print_feature("TS_USE_LINUX_NATIVE_AIO", TS_USE_LINUX_NATIVE_AIO, json);
+  print_feature("TS_HAS_SO_PEERCRED", TS_HAS_SO_PEERCRED, json);
+  print_feature("TS_USE_REMOTE_UNWINDING", TS_USE_REMOTE_UNWINDING, json);
+  print_feature("GETHOSTBYNAME_R_GLIBC2", GETHOSTBYNAME_R_GLIBC2, json);
+  print_feature("SIZEOF_VOID_POINTER", SIZEOF_VOID_POINTER, json);
+  print_feature("TS_IP_TRANSPARENT", TS_IP_TRANSPARENT, json);
+  print_feature("TS_HAS_128BIT_CAS", TS_HAS_128BIT_CAS, json);
+  print_feature("TS_HAS_TESTS", TS_HAS_TESTS, json);
+  print_feature("TS_HAS_WCCP", TS_HAS_WCCP, json);
+  print_feature("TS_MAX_THREADS_IN_EACH_THREAD_TYPE", TS_MAX_THREADS_IN_EACH_THREAD_TYPE, json);
+  print_feature("TS_MAX_NUMBER_EVENT_THREADS", TS_MAX_NUMBER_EVENT_THREADS, json);
+  print_feature("TS_MAX_HOST_NAME_LEN", TS_MAX_HOST_NAME_LEN, json);
+  print_feature("TS_MAX_API_STATS", TS_MAX_API_STATS, json);
+  print_feature("SPLIT_DNS", SPLIT_DNS, json);
+  print_feature("HTTP_CACHE", HTTP_CACHE, json);
+  print_feature("TS_PKGSYSUSER", TS_PKGSYSUSER, json);
+  print_feature("TS_PKGSYSGROUP", TS_PKGSYSGROUP, json, true);
+  if (json) {
+    printf("}\n");
+  }
+}
+
 
 static void
-printvar(const char *name, char *val)
+print_var(const char *name, char *val)
 {
   printf("%s: %s\n", name, val);
   ats_free(val);
 }
 
+static void
+produce_layout()
+{
+  Layout::create();
+
+  RecProcessInit(RECM_STAND_ALONE, NULL /* diags */);
+  LibRecordsConfigInit();
+
+  printf("%s: %s\n", "PREFIX", Layout::get()->prefix);
+  print_var("BINDIR", RecConfigReadBinDir());
+  print_var("SYSCONFDIR", RecConfigReadConfigDir());
+  print_var("LIBDIR", Layout::get()->libdir);
+  print_var("LOGDIR", RecConfigReadLogDir());
+  print_var("RUNTIMEDIR", RecConfigReadRuntimeDir());
+  print_var("PLUGINDIR", RecConfigReadPrefixPath("proxy.config.plugin.plugin_dir"));
+  print_var("INCLUDEDIR", Layout::get()->includedir);
+  print_var("SNAPSHOTDIR", RecConfigReadSnapshotDir());
+
+  print_var("records.config", RecConfigReadConfigPath(NULL, REC_CONFIG_FILE));
+  print_var("remap.config", RecConfigReadConfigPath("proxy.config.url_remap.filename"));
+  print_var("plugin.config", RecConfigReadConfigPath(NULL, "plugin.config"));
+  print_var("ssl_multicert.config", RecConfigReadConfigPath("proxy.config.ssl.server.multicert.filename"));
+  print_var("storage.config", RecConfigReadConfigPath("proxy.config.cache.storage_filename"));
+  print_var("hosting.config", RecConfigReadConfigPath("proxy.config.cache.hosting_filename"));
+  print_var("volume.config", RecConfigReadConfigPath("proxy.config.cache.volume_filename"));
+  print_var("ip_allow.config", RecConfigReadConfigPath("proxy.config.cache.ip_allow.filename"));
+}
+
 int
 main(int /* argc ATS_UNUSED */, const char **argv)
 {
@@ -47,28 +172,10 @@ main(int /* argc ATS_UNUSED */, const char **argv)
   // Process command line arguments and dump into variables
   process_args(&appVersionInfo, argument_descriptions, countof(argument_descriptions), argv);
 
-  Layout::create();
-  RecProcessInit(RECM_STAND_ALONE, NULL /* diags */);
-  LibRecordsConfigInit();
-
-  printf("%s: %s\n", "PREFIX", Layout::get()->prefix);
-  printvar("BINDIR", RecConfigReadBinDir());
-  printvar("SYSCONFDIR", RecConfigReadConfigDir());
-  printvar("LIBDIR", Layout::get()->libdir);
-  printvar("LOGDIR", RecConfigReadLogDir());
-  printvar("RUNTIMEDIR", RecConfigReadRuntimeDir());
-  printvar("PLUGINDIR", RecConfigReadPrefixPath("proxy.config.plugin.plugin_dir"));
-  printvar("INCLUDEDIR", Layout::get()->includedir);
-  printvar("SNAPSHOTDIR", RecConfigReadSnapshotDir());
-
-  printvar("records.config", RecConfigReadConfigPath(NULL, REC_CONFIG_FILE));
-  printvar("remap.config", RecConfigReadConfigPath("proxy.config.url_remap.filename"));
-  printvar("plugin.config", RecConfigReadConfigPath(NULL, "plugin.config"));
-  printvar("ssl_multicert.config", RecConfigReadConfigPath("proxy.config.ssl.server.multicert.filename"));
-  printvar("storage.config", RecConfigReadConfigPath("proxy.config.cache.storage_filename"));
-  printvar("hosting.config", RecConfigReadConfigPath("proxy.config.cache.hosting_filename"));
-  printvar("volume.config", RecConfigReadConfigPath("proxy.config.cache.volume_filename"));
-  printvar("ip_allow.config", RecConfigReadConfigPath("proxy.config.cache.ip_allow.filename"));
-
+  if (cl.features) {
+    produce_features(0 != cl.json);
+  } else {
+    produce_layout();
+  }
   exit(0);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b3ec3c56/iocore/hostdb/HostDB.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index eb33f7f..ec4c463 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -2390,7 +2390,6 @@ struct ShowHostDB : public ShowCont {
 
   ShowHostDB(Continuation *c, HTTPHdr *h) : ShowCont(c, h), name(0), port(0), force(0)
   {
-
     ats_ip_invalidate(&ip);
     SET_HANDLER(&ShowHostDB::showMain);
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b3ec3c56/lib/ts/ink_config.h.in
----------------------------------------------------------------------
diff --git a/lib/ts/ink_config.h.in b/lib/ts/ink_config.h.in
index 9ae0160..ca4c69e 100644
--- a/lib/ts/ink_config.h.in
+++ b/lib/ts/ink_config.h.in
@@ -28,6 +28,8 @@
 // Note: All "defines" should be prefixed with TS_ when appropriate, please
 // don't use ATS_ any more.
 
+// Note 2: If you make changes here, please update the traffic_layout.cc file as well.
+
 /* GENERATED FILE WARNING!  DO NOT EDIT ink_config.h
  *
  * You must modify ink_config.h.in instead.
@@ -92,15 +94,15 @@
 #define TS_HAS_WCCP                    @has_wccp@
 
 #define TS_MAX_THREADS_IN_EACH_THREAD_TYPE  @max_threads_per_type@
-#define TS_MAX_NUMBER_EVENT_THREADS  @max_event_threads@
+#define TS_MAX_NUMBER_EVENT_THREADS    @max_event_threads@
 
 #define TS_MAX_HOST_NAME_LEN           @max_host_name_len@
 
-# define TS_MAX_API_STATS               @max_api_stats@
+#define TS_MAX_API_STATS               @max_api_stats@
 
 
-# define SPLIT_DNS                      1
-# define HTTP_CACHE                     1
+#define SPLIT_DNS                      1
+#define HTTP_CACHE                     1
 
 /* Defaults for user / group */
 #define TS_PKGSYSUSER                   "@pkgsysuser@"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b3ec3c56/proxy/hdrs/MIME.h
----------------------------------------------------------------------
diff --git a/proxy/hdrs/MIME.h b/proxy/hdrs/MIME.h
index 4d9b2b6..eb57f88 100644
--- a/proxy/hdrs/MIME.h
+++ b/proxy/hdrs/MIME.h
@@ -1330,7 +1330,6 @@ MIMEHdr::field_value_append(MIMEField *field, const char *value_str, int value_l
 }
 
 
-
 inline void
 MIMEHdr::field_combine_dups(MIMEField *field, bool prepend_comma, const char separator)
 {