[trafficserver] 02/02: cppapi: InterceptPlugin fix

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit c9422368cc0c83d50712d0552feba930fdb903d7
Author: Otto van der Schaaf 
AuthorDate: Thu Jul 5 13:27:03 2018 +

cppapi: InterceptPlugin fix

This change unbreaks using cppapi ServerIntercepts

(Ran into a hanging FastCGI plugin while trying address comments in

(cherry picked from commit 5a29260030aa36ebcd87ec7867a9de66d0dd1f9d)
---
 lib/cppapi/InterceptPlugin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cppapi/InterceptPlugin.cc b/lib/cppapi/InterceptPlugin.cc
index d47e52a..71c1da8 100644
--- a/lib/cppapi/InterceptPlugin.cc
+++ b/lib/cppapi/InterceptPlugin.cc
@@ -84,7 +84,7 @@ struct InterceptPlugin::State {
   TSAction timeout_action_ = nullptr;
   bool plugin_io_done_ = false;
 
-  State(TSCont cont, InterceptPlugin *plugin) : cont_(cont)
+  State(TSCont cont, InterceptPlugin *plugin) : cont_(cont), plugin_(plugin)
   {
 plugin_mutex_ = plugin->getMutex();
 http_parser_  = TSHttpParserCreate();



[trafficserver] branch 8.0.x updated (a968857 -> c942236)

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a change to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from a968857  Fixes the renamed RenameTSHttpTxnSetHttpRetStatus() API
 new 325b992  Add feature to use modified cache-key-url for parent 
selection.
 new c942236  cppapi: InterceptPlugin fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 lib/cppapi/InterceptPlugin.cc  |   2 +-
 plugins/experimental/cache_range_requests/README   |  20 
 .../cache_range_requests/cache_range_requests.cc   | 133 +++--
 3 files changed, 141 insertions(+), 14 deletions(-)



[trafficserver] 01/02: Add feature to use modified cache-key-url for parent selection.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 325b99237efddb04113f5e385d4d76440a2ae4b6
Author: Jeffrey Bevill 
AuthorDate: Tue Jul 3 20:32:46 2018 +

Add feature to use modified cache-key-url for parent selection.

(cherry picked from commit 148d9897cbbc5d2d95b18d624ed29a6cb5e3ab8d)
---
 plugins/experimental/cache_range_requests/README   |  20 
 .../cache_range_requests/cache_range_requests.cc   | 133 +++--
 2 files changed, 140 insertions(+), 13 deletions(-)

diff --git a/plugins/experimental/cache_range_requests/README 
b/plugins/experimental/cache_range_requests/README
index 18a88c6..4844156 100644
--- a/plugins/experimental/cache_range_requests/README
+++ b/plugins/experimental/cache_range_requests/README
@@ -34,3 +34,23 @@ Configuration:
 Or for a global plugin where all range requests are processed,
 Add cache_range_requests.so to the plugin.config
 
+Parent Selection Mode (consisent-hash only):
+  
+default: Parent selection is based solely on the hash of a URL Path
+ In this mode, all partial content of a URL is requested from the 
same 
+ upstream parent cache listed in parent.config
+ 
+cache_key_url: Parent selection is based on the full cache_key_url which 
+   includes information about the partial content range.
+   In this mode, all requests (include partial content) will 
use
+   consistent hashing method for parent selection. 
+
+To enable cache_key_url parent select mode, the following param must be 
set:
+
+Global Plugin (plugin.config):
+  
+  cache_range_requests.so ps_mode:cache_key_url
+
+Remap Plugin (remap.config):
+  
+@plugin=cache_range_requests.so 
@pparam=ps_mode:cache_key_url
diff --git a/plugins/experimental/cache_range_requests/cache_range_requests.cc 
b/plugins/experimental/cache_range_requests/cache_range_requests.cc
index 14bbe57..b0b61ec 100644
--- a/plugins/experimental/cache_range_requests/cache_range_requests.cc
+++ b/plugins/experimental/cache_range_requests/cache_range_requests.cc
@@ -35,18 +35,76 @@
 #define DEBUG_LOG(fmt, ...) TSDebug(PLUGIN_NAME, "[%s:%d] %s(): " fmt, 
__FILE__, __LINE__, __func__, ##__VA_ARGS__)
 #define ERROR_LOG(fmt, ...) TSError("[%s:%d] %s(): " fmt, __FILE__, __LINE__, 
__func__, ##__VA_ARGS__)
 
+typedef enum parent_select_mode {
+  PS_DEFAULT,  // Default ATS parent selection mode
+  PS_CACHEKEY_URL, // Set parent selection url to cache_key url
+} parent_select_mode_t;
+
+struct pluginconfig {
+  parent_select_mode_t ps_mode;
+};
+
 struct txndata {
   char *range_value;
 };
 
 static int handle_read_request_header(TSCont, TSEvent, void *);
-static void range_header_check(TSHttpTxn txnp);
+static void range_header_check(TSHttpTxn txnp, struct pluginconfig *pc);
 static void handle_send_origin_request(TSCont, TSHttpTxn, struct txndata *);
 static void handle_client_send_response(TSHttpTxn, struct txndata *);
 static void handle_server_read_response(TSHttpTxn, struct txndata *);
 static int remove_header(TSMBuffer, TSMLoc, const char *, int);
 static bool set_header(TSMBuffer, TSMLoc, const char *, int, const char *, 
int);
 static int transaction_handler(TSCont, TSEvent, void *);
+static struct pluginconfig *create_pluginconfig(int argc, const char *argv[]);
+static void delete_pluginconfig(struct pluginconfig *);
+
+// pluginconfig struct (global plugin only)
+static struct pluginconfig *gPluginConfig = nullptr;
+
+/**
+ * Creates pluginconfig data structure
+ * Sets default parent url selection mode
+ * Walk plugin argument list and updates config
+ */
+static struct pluginconfig *
+create_pluginconfig(int argc, const char *argv[])
+{
+  struct pluginconfig *pc = nullptr;
+
+  pc = (struct pluginconfig *)TSmalloc(sizeof(struct pluginconfig));
+
+  if (nullptr == pc) {
+ERROR_LOG("Can't allocate pluginconfig");
+return nullptr;
+  }
+
+  // Plugin uses default ATS selection (hash of URL path)
+  pc->ps_mode = PS_DEFAULT;
+
+  // Walk through param list.
+  for (int c = 0; c < argc; c++) {
+if (strcmp("ps_mode:cache_key_url", argv[c]) == 0) {
+  pc->ps_mode = PS_CACHEKEY_URL;
+  break;
+}
+  }
+
+  return pc;
+}
+
+/**
+ * Destroy pluginconfig data stucture.
+ */
+static void
+delete_pluginconfig(struct pluginconfig *pc)
+{
+  if (nullptr != pc) {
+DEBUG_LOG("Delete struct pluginconfig");
+TSfree(pc);
+pc = nullptr;
+  }
+}
 
 /**
  * Entry point when used as a global plugin.
@@ -57,7 +115,7 @@ handle_read_request_header(TSCont txn_contp, TSEvent event, 
void *edata)
 {
   TSHttpTxn txnp = static_cast(edata);
 
-  range_header_check(txnp);
+  range_header_check(txnp, gPluginConfig);
 
   TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
   return 0;
@@ -74,11 +132,11 @@ handle_read_request_header(TSCont tx

[trafficserver] branch 8.0.x updated (c942236 -> ea89d09)

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a change to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from c942236  cppapi: InterceptPlugin fix
 new d669199  Runroot: add an option to specify copy style
 new 7899e8e  Runroot: add new option to specify layout during creating
 new ea89d09  Runroot: Add feature to use runroot by providing yaml file

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/appendices/command-line/traffic_layout.en.rst | 98 --
 lib/records/RecConfigParse.cc | 17 
 lib/ts/runroot.cc | 85 ++-
 lib/ts/runroot.h  |  7 +-
 src/traffic_layout/engine.cc  | 99 ---
 src/traffic_layout/engine.h   | 10 ++-
 src/traffic_layout/file_system.cc | 26 +++---
 src/traffic_layout/file_system.h  |  5 +-
 src/traffic_layout/traffic_layout.cc  |  2 -
 tests/gold_tests/runroot/runroot_error.test.py|  4 +-
 tests/gold_tests/runroot/runroot_init.test.py |  9 ++-
 11 files changed, 249 insertions(+), 113 deletions(-)



[trafficserver] 02/03: Runroot: add new option to specify layout during creating

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 7899e8e34ede26adb77aa65d1872254d70ddbda0
Author: Xavier Chi 
AuthorDate: Tue Jul 10 16:04:18 2018 -0500

Runroot: add new option to specify layout during creating


(cherry picked from commit 5ca1665f6928f347af16b1e193e791d7a6a2ce7f)
---
 doc/appendices/command-line/traffic_layout.en.rst |  4 ++
 lib/records/RecConfigParse.cc | 17 
 lib/ts/runroot.cc |  6 +++
 lib/ts/runroot.h  |  3 ++
 src/traffic_layout/engine.cc  | 48 +++
 src/traffic_layout/engine.h   |  7 +++-
 src/traffic_layout/file_system.cc |  2 +-
 src/traffic_layout/traffic_layout.cc  |  2 -
 tests/gold_tests/runroot/runroot_init.test.py |  9 +++--
 9 files changed, 81 insertions(+), 17 deletions(-)

diff --git a/doc/appendices/command-line/traffic_layout.en.rst 
b/doc/appendices/command-line/traffic_layout.en.rst
index c236816..a56c7a0 100644
--- a/doc/appendices/command-line/traffic_layout.en.rst
+++ b/doc/appendices/command-line/traffic_layout.en.rst
@@ -103,6 +103,10 @@ Options
 
 Specify the way of copying executables when creating runroot
 
+.. option:: --layout=[]
+
+Use specific layout (providing YAML file) to create runroot
+
 
 Examples
 
diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc
index 3042b0e..81fecad 100644
--- a/lib/records/RecConfigParse.cc
+++ b/lib/records/RecConfigParse.cc
@@ -28,6 +28,7 @@
 #include "ts/Tokenizer.h"
 #include "ts/ink_defs.h"
 #include "ts/ink_string.h"
+#include "ts/runroot.h"
 
 #include "P_RecFile.h"
 #include "P_RecUtils.h"
@@ -83,6 +84,20 @@ RecFileImport_Xmalloc(const char *file, char **file_buf, int 
*file_size)
 }
 
 //-
+// RecConfigOverrideFromRunroot
+//-
+bool
+RecConfigOverrideFromRunroot(const char *name)
+{
+  if (use_runroot()) {
+if (!strcmp(name, "proxy.config.bin_path") || !strcmp(name, 
"proxy.config.local_state_dir") ||
+!strcmp(name, "proxy.config.log.logfile_dir") || !strcmp(name, 
"proxy.config.plugin.plugin_dir"))
+  return true;
+  }
+  return false;
+}
+
+//-
 // RecConfigOverrideFromEnvironment
 //-
 const char *
@@ -106,6 +121,8 @@ RecConfigOverrideFromEnvironment(const char *name, const 
char *value)
   envval = getenv((const char *)envname);
   if (envval) {
 return envval;
+  } else if (RecConfigOverrideFromRunroot(name)) {
+return nullptr;
   }
 
   return value;
diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index 119cd56..38edaa4 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -246,3 +246,9 @@ check_runroot()
   }
   return runroot_map(using_runroot);
 }
+
+bool
+use_runroot()
+{
+  return !using_runroot.empty();
+}
diff --git a/lib/ts/runroot.h b/lib/ts/runroot.h
index 4256cfc..a06636f 100644
--- a/lib/ts/runroot.h
+++ b/lib/ts/runroot.h
@@ -61,3 +61,6 @@ RunrootMapType runroot_map(const std::string &prefix);
 
 // help check runroot for layout
 RunrootMapType check_runroot();
+
+// helper method for records config to check using runroot or not
+bool use_runroot();
diff --git a/src/traffic_layout/engine.cc b/src/traffic_layout/engine.cc
index b6af4f6..764514d 100644
--- a/src/traffic_layout/engine.cc
+++ b/src/traffic_layout/engine.cc
@@ -44,7 +44,7 @@
 #include 
 
 // for nftw check_directory
-std::string directory_check = "";
+std::string directory_check;
 
 // check if we can create the runroot using path
 // return true if the path is good to use
@@ -149,6 +149,7 @@ RunrootEngine::runroot_help_message(const bool runflag, 
const bool cleanflag, co
  "--absoluteProduce absolute path in the yaml file\n"
  "--run-root(=/path)  Using specified TS_RUNROOT as sandbox\n"
  "--copy-style=[STYLE] Specify style (FULL, HARD, SOFT) when 
copying executable\n"
+ "--layout=[/path] Use specific layout (providing yaml file) 
to create runroot\n"
   << std::endl;
   }
   if (cleanflag) {
@@ -192,7 +193,7 @@ RunrootEngine::runroot_parse()
   abs_flag = true;
   continue;
 }
-if (argument.substr(0, RUNROOT_WORD_LENGTH) == "--run-root") {
+if (argument.substr(0, RUNROOT_WORD.size()) == RUNROOT_WORD) {
   continue;
 }
 // set init flag
@@ -218,8 +219,8 @@ RunrootEngine::runroot_parse()
   fix_flag = true;
   continue;
 }
-if (argument.substr(0, COPYSTYLE_WORD_LENGTH) == "--copy-style") {
-  std::string style = arg

[trafficserver] 03/03: Runroot: Add feature to use runroot by providing yaml file

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit ea89d097086392e684034d95e2e74cad9b3c1f50
Author: Xavier Chi 
AuthorDate: Fri Jul 20 15:14:18 2018 -0500

Runroot: Add feature to use runroot by providing yaml file

(cherry picked from commit 37aa9fefc729ab320b2acffca480ce37ea3f21c6)
---
 lib/ts/runroot.cc  | 81 +-
 lib/ts/runroot.h   |  4 --
 src/traffic_layout/engine.cc   | 39 -
 tests/gold_tests/runroot/runroot_error.test.py |  4 +-
 4 files changed, 80 insertions(+), 48 deletions(-)

diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index 38edaa4..8e5f0f4 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -38,6 +38,7 @@ datadir, libexecdir, libdir, runtimedir, cachedir.
 */
 
 #include "ts/ink_error.h"
+#include "ts/ink_file.h"
 #include "ts/I_Layout.h"
 #include "runroot.h"
 
@@ -47,27 +48,33 @@ datadir, libexecdir, libdir, runtimedir, cachedir.
 #include 
 #include 
 
-static std::string using_runroot = {};
+static std::string runroot_file = {};
 
 // the function for the checking of the yaml file in the passed in path
-// if found return the path, if not return empty string
-std::string
-check_path(const std::string &path)
+// if found return the path to the yaml file, if not return empty string.
+static std::string
+get_yaml_path(const std::string &path)
 {
-  std::string whole_path = path;
-  std::string yaml_path  = Layout::relative_to(whole_path, "runroot_path.yml");
   std::ifstream check_file;
-  check_file.open(yaml_path);
-  if (check_file.good()) {
-return whole_path;
+  if (ink_file_is_directory(path.c_str())) {
+std::string yaml_path = Layout::relative_to(path, "runroot_path.yml");
+check_file.open(yaml_path);
+if (check_file.good()) {
+  return yaml_path;
+}
+  } else {
+check_file.open(path);
+if (check_file.good() && path.substr(path.find_last_of("/") + 1) == 
"runroot_path.yml") {
+  return path;
+}
   }
   return {};
 }
 
 // the function for the checking of the yaml file in passed in directory or 
parent directory
-// if found return the parent path containing the yaml file
-std::string
-check_parent_path(const std::string &path)
+// if found return the parent path to the yaml file
+static std::string
+get_parent_yaml_path(const std::string &path)
 {
   std::string whole_path = path;
   if (whole_path.back() == '/') {
@@ -79,25 +86,17 @@ check_parent_path(const std::string &path)
 if (whole_path.empty()) {
   return {};
 }
-if (!check_path(whole_path).empty()) {
-  return whole_path;
+std::string yaml_file = get_yaml_path(whole_path);
+if (!yaml_file.empty()) {
+  return yaml_file;
 }
 whole_path = whole_path.substr(0, whole_path.find_last_of("/"));
   }
   return {};
 }
 
-// until I get a  impl in
-bool
-is_directory(const char *directory)
-{
-  struct stat buffer;
-  int result = stat(directory, &buffer);
-  return (!result && (S_IFDIR & buffer.st_mode)) ? true : false;
-}
-
 // handler for ts runroot
-// this function set up using_runroot
+// this function set up runroot_file
 void
 runroot_handler(const char **argv, bool json)
 {
@@ -121,12 +120,12 @@ runroot_handler(const char **argv, bool json)
   if (!arg.empty() && arg != prefix) {
 // 1. pass in path
 prefix += "=";
-path = check_path(arg.substr(prefix.size(), arg.size() - 1));
+path = get_yaml_path(arg.substr(prefix.size(), arg.size() - 1));
 if (!path.empty()) {
   if (!json) {
 ink_notice("using command line path as RUNROOT");
   }
-  using_runroot = path;
+  runroot_file = path;
   return;
 } else {
   if (!json) {
@@ -137,10 +136,10 @@ runroot_handler(const char **argv, bool json)
 
   // 2. check Environment variable
   char *env_val = getenv("TS_RUNROOT");
-  if ((env_val != nullptr) && is_directory(env_val)) {
-path = check_path(env_val);
+  if (env_val) {
+path = get_yaml_path(env_val);
 if (!path.empty()) {
-  using_runroot = env_val;
+  runroot_file = path;
   if (!json) {
 ink_notice("using the environment variable TS_RUNROOT");
   }
@@ -155,9 +154,9 @@ runroot_handler(const char **argv, bool json)
   // 3. find cwd or parent path of cwd to check
   char cwd[PATH_MAX] = {0};
   if (getcwd(cwd, sizeof(cwd)) != nullptr) {
-path = check_parent_path(cwd);
+path = get_parent_yaml_path(cwd);
 if (!path.empty()) {
-  using_runroot = path;
+  runroot_file = path;
   if (!json) {
 ink_notice("using cwd as TS_RUNROOT");
   }
@@ -170,9 +169,9 @@ runroot_handler(const char **argv, bool json)
   if ((argv[0] != nullptr) && realpath(argv[0], RealBinPath) != nullptr) {
 std::string bindir = RealBinPath;
 bindir = bindir.substr(0, bindir.find_last_

[trafficserver] 01/03: Runroot: add an option to specify copy style

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit d669199869519c356b72cbdd0d946e83429b50ae
Author: Xavier Chi 
AuthorDate: Fri Jun 29 10:30:19 2018 -0500

Runroot: add an option to specify copy style


(cherry picked from commit 58beea4fec0b84205d502e08fadd8b3d19eb2ec7)
---
 doc/appendices/command-line/traffic_layout.en.rst | 94 +--
 src/traffic_layout/engine.cc  | 16 +++-
 src/traffic_layout/engine.h   |  5 ++
 src/traffic_layout/file_system.cc | 24 --
 src/traffic_layout/file_system.h  |  5 +-
 5 files changed, 92 insertions(+), 52 deletions(-)

diff --git a/doc/appendices/command-line/traffic_layout.en.rst 
b/doc/appendices/command-line/traffic_layout.en.rst
index e9eca56..c236816 100644
--- a/doc/appendices/command-line/traffic_layout.en.rst
+++ b/doc/appendices/command-line/traffic_layout.en.rst
@@ -20,22 +20,12 @@
 traffic_layout
 **
 
+
 Synopsis
 
 :program:`traffic_layout` SUBCOMMAND [OPTIONS]
 
-Options
-=
-.. program:: traffic_layout
-
-.. option:: --run-root=[]
-
-   Use the run root file at :arg:`path`.
-
-.. option:: -V, --version
-
-Print version information and exit.
-
+===
 Environment
 ===
 
@@ -43,8 +33,9 @@ Environment
 
The path to the run root file. It has the same effect as the command line 
option :option:`--run-root`.
 
+===
 Description
-=
+===
 Document for the special functionality of ``runroot`` inside 
:program:`traffic_layout`. This feature
 is for the setup of traffic server runroot. It will create a runtime sandbox 
for any program of
 traffic server to run under.
@@ -60,59 +51,78 @@ How it works
 #. Emit a yaml file that defines layout structure for other programs to use 
(relative path).
 #. Users are able to remove runroot and verify permission of the runroot.
 
+===
 Subcommands
-=
+===
 
-- Initialize the runroot: ::
+``init``
+   Use the current working directory or the specific path to create runroot. 
+   The path can be relative or set up in :envvar:`TS_RUNROOT`.
 
-  traffic_layout init (--path /path/to/sandbox/)
+``remove``
+   Find the sandbox to remove in following order: 
+  #. specified in --path as absolute or relative.
+  #. ENV variable: :envvar:`TS_RUNROOT`
+  #. current working directory
+  #. installed directory.
+   
+``verify``
+   Verify the permission of the sandbox.
+
+===
+Options
+===
+.. program:: traffic_layout
 
-  Use the current working directory or the specific path to create runroot.
-  The path can be relative or set up in :envvar:`TS_RUNROOT`.
+.. option:: --run-root=[]
 
+Use the run root file at :arg:`path`.
+   
+.. option:: -V, --version
 
-- Remove the runroot: ::
+Print version information and exit.
 
-  traffic_layout remove (--path /path/to/sandbox/)
+.. option:: -h, --help
 
-  Find the sandbox to remove in following order: 
+Print usage information and exit.
 
-1. specified in --path as absolute or relative.
-2. :envvar:`TS_RUNROOT`
-3. current working directory
-4. installed directory.
+.. option:: --force
 
-- Verify the runroot: ::
+Force init will create sandbox even if the directory is not empty.
+Force remove will remove a directory even if directory has no yaml file.
 
-  traffic_layout verify (--path /path/to/sandbox/)
+.. option:: --absolute
 
-  Verify the permission of the sandbox.
+Put directories in the yaml file in the form of absolute path when 
creating.
+
+.. option:: --fix
 
-Subcommands options

+Fix the permission issues verify found. ``--fix`` requires root privilege 
(sudo).
 
-- Force option: ::
+.. option:: --copy-style=[HARD/SOFT/FULL]
 
-  traffic_layout init --force (--path /path/to/sandbox)
-  traffic_layout remove --force (--path /path/to/sandbox)
+Specify the way of copying executables when creating runroot
 
-  Force init will create sandbox even if the directory is not empty.
-  Force remove will remove a directory even if directory has no yaml file.
+
+Examples
+
 
-- Absolute option: ::
+Initialize the runroot. ::
 
-  traffic_layout init --absolute (--path /path/to/sandbox)
+traffic_layout init (--path /path/to/sandbox/) (--force) (--absolute) 
(--copy-style=[HARD/SOFT/FULL])
 
-  create the sandbox and put directories in the yaml file in the form of 
absolute path.
+Remove the runroot. ::
 
-- Fix option: ::
+traffic_layout remove (--path /path/to/sandbox/) (--force)
 
-  traffic_layout verify --fix (--path /path/to/sandbox)
+Verify the runroot. ::
+
+traffic_layout verify (--path /path/to/sandbox/) (--fix)
 
-  Fix th

[trafficserver] 01/02: traffic_manager: Cleanup handling of proxy args.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit f447876d1ea5236f89ed18c10e546723883aab50
Author: Alan M. Carroll 
AuthorDate: Fri Jun 29 11:24:08 2018 -0500

traffic_manager: Cleanup handling of proxy args.

(cherry picked from commit e10da228172ac548ec7d497850c6a5e9d7b43114)
---
 mgmt/LocalManager.cc   | 56 +-
 mgmt/LocalManager.h|  4 ++-
 mgmt/api/CoreAPI.cc|  2 +-
 src/traffic_manager/traffic_manager.cc | 22 -
 4 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 907650c..b31d00f 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -32,12 +32,17 @@
 #include "ts/ink_cap.h"
 #include "FileManager.h"
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #if TS_USE_POSIX_CAP
 #include 
 #endif
 
-#define MGMT_OPT "-M"
+using namespace std::literals;
+static const std::string_view MGMT_OPT{"-M"};
 
 void
 LocalManager::mgmtCleanup()
@@ -253,7 +258,6 @@ LocalManager::~LocalManager()
   ats_free(absolute_proxy_binary);
   ats_free(proxy_name);
   ats_free(proxy_binary);
-  ats_free(proxy_options);
   ats_free(env_prep);
 }
 
@@ -883,52 +887,48 @@ LocalManager::startProxy(const char *onetime_options)
   } else {
 int i = 0;
 char *options[32], *last, *tok;
-bool open_ports_p = false;
-char real_proxy_options[OPTIONS_SIZE];
+char options_buffer[OPTIONS_SIZE];
+ts::FixedBufferWriter w{options_buffer, OPTIONS_SIZE};
 
-ink_strlcpy(real_proxy_options, proxy_options, OPTIONS_SIZE);
-if (onetime_options && *onetime_options) {
-  ink_strlcat(real_proxy_options, " ", OPTIONS_SIZE);
-  ink_strlcat(real_proxy_options, onetime_options, OPTIONS_SIZE);
-}
+w.clip(1);
+w.print("{}{}", ts::bwf::OptionalAffix(proxy_options), 
ts::bwf::OptionalAffix(onetime_options));
 
 // Make sure we're starting the proxy in mgmt mode
-if (strstr(real_proxy_options, MGMT_OPT) == nullptr) {
-  ink_strlcat(real_proxy_options, " ", OPTIONS_SIZE);
-  ink_strlcat(real_proxy_options, MGMT_OPT, OPTIONS_SIZE);
+if (w.view().find(MGMT_OPT) == std::string_view::npos) {
+  w.write(MGMT_OPT);
+  w.write(' ');
 }
 
-// Check if we need to pass down port/fd information to
-// traffic_server by seeing if there are any open ports.
-for (int i = 0, limit = m_proxy_ports.size(); !open_ports_p && i < limit; 
++i) {
-  if (ts::NO_FD != m_proxy_ports[i].m_fd) {
-open_ports_p = true;
-  }
-}
-
-if (open_ports_p) {
+// Pass down port/fd information to traffic_server if there are any open 
ports.
+if (std::any_of(m_proxy_ports.begin(), m_proxy_ports.end(), 
[](HttpProxyPort &p) { return ts::NO_FD != p.m_fd; })) {
   char portbuf[128];
   bool need_comma_p = false;
 
-  ink_strlcat(real_proxy_options, " --httpport ", OPTIONS_SIZE);
+  w.write("--httpport "sv);
   for (auto &p : m_proxy_ports) {
 if (ts::NO_FD != p.m_fd) {
   if (need_comma_p) {
-ink_strlcat(real_proxy_options, ",", OPTIONS_SIZE);
+w.write(',');
   }
   need_comma_p = true;
   p.print(portbuf, sizeof(portbuf));
-  ink_strlcat(real_proxy_options, (const char *)portbuf, OPTIONS_SIZE);
+  w.write(portbuf);
 }
   }
 }
 
-Debug("lm", "[LocalManager::startProxy] Launching %s with options '%s'", 
absolute_proxy_binary, real_proxy_options);
+w.extend(1);
+w.write('\0'); // null terminate.
+
+Debug("lm", "[LocalManager::startProxy] Launching %s '%s'", 
absolute_proxy_binary, w.data());
 
+// Unfortunately the normally obnoxious null writing of strtok is in this 
case a required
+// side effect and other alternatives are noticeably more clunky.
 ink_zero(options);
-options[0]   = absolute_proxy_binary;
-i= 1;
-tok  = strtok_r(real_proxy_options, " ", &last);
+options[0] = absolute_proxy_binary;
+i  = 1;
+tok= strtok_r(options_buffer, " ", &last);
+Debug("lm", "opt %d = '%s'", i, tok);
 options[i++] = tok;
 while (i < 32 && (tok = strtok_r(nullptr, " ", &last))) {
   Debug("lm", "opt %d = '%s'", i, tok);
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 4cc5257..4ff3591 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -33,6 +33,8 @@
 
 #pragma once
 
+#include 
+
 #include "Alarms.h"
 #include "BaseManager.h"
 #include 
@@ -119,7 +121,7 @@ public:
   char *absolute_proxy_binary;
   char *proxy_name;
   char *proxy_binary;
-  char *proxy_options = nullptr; // These options should persist across proxy 
reboots
+  std::string proxy_options; // These options should persist across proxy 
reboots
   char *env_prep;
 
   int process_s

[trafficserver] branch 8.0.x updated (ea89d09 -> 1b2305c)

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a change to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from ea89d09  Runroot: Add feature to use runroot by providing yaml file
 new f447876  traffic_manager: Cleanup handling of proxy args.
 new 1b2305c  Runroot: pass runroot down from manager and error message 
update

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 lib/records/RecConfigParse.cc|  2 +-
 lib/ts/runroot.cc| 49 +--
 lib/ts/runroot.h |  4 +-
 mgmt/LocalManager.cc | 62 ++--
 mgmt/LocalManager.h  |  4 +-
 mgmt/api/CoreAPI.cc  |  2 +-
 src/traffic_layout/engine.cc | 14 --
 src/traffic_manager/traffic_manager.cc   | 25 --
 tests/gold_tests/runroot/runroot_error.test.py   |  7 +--
 tests/gold_tests/runroot/runroot_init.test.py| 15 +++---
 tests/gold_tests/runroot/runroot_manager.test.py | 52 
 tests/gold_tests/runroot/runroot_remove.test.py  | 12 ++---
 tests/gold_tests/runroot/runroot_use.test.py |  7 +--
 tests/gold_tests/runroot/runroot_verify.test.py  |  5 +-
 14 files changed, 151 insertions(+), 109 deletions(-)
 create mode 100644 tests/gold_tests/runroot/runroot_manager.test.py



[trafficserver] 02/02: Runroot: pass runroot down from manager and error message update

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 1b2305cb5b078f9d1fff5b3196af63a615b31520
Author: Xavier Chi 
AuthorDate: Thu Aug 2 14:16:54 2018 -0500

Runroot: pass runroot down from manager and error message update


(cherry picked from commit 39b3273a703b15e2d619519f7952e37504738956)
---
 lib/records/RecConfigParse.cc|  2 +-
 lib/ts/runroot.cc| 49 +++---
 lib/ts/runroot.h |  4 +-
 mgmt/LocalManager.cc | 10 +
 src/traffic_layout/engine.cc | 14 ---
 src/traffic_manager/traffic_manager.cc   |  3 ++
 tests/gold_tests/runroot/runroot_error.test.py   |  7 +---
 tests/gold_tests/runroot/runroot_init.test.py| 15 +++
 tests/gold_tests/runroot/runroot_manager.test.py | 52 
 tests/gold_tests/runroot/runroot_remove.test.py  | 12 ++
 tests/gold_tests/runroot/runroot_use.test.py |  7 +---
 tests/gold_tests/runroot/runroot_verify.test.py  |  5 +--
 12 files changed, 115 insertions(+), 65 deletions(-)

diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc
index 81fecad..b690375 100644
--- a/lib/records/RecConfigParse.cc
+++ b/lib/records/RecConfigParse.cc
@@ -89,7 +89,7 @@ RecFileImport_Xmalloc(const char *file, char **file_buf, int 
*file_size)
 bool
 RecConfigOverrideFromRunroot(const char *name)
 {
-  if (use_runroot()) {
+  if (!get_runroot().empty()) {
 if (!strcmp(name, "proxy.config.bin_path") || !strcmp(name, 
"proxy.config.local_state_dir") ||
 !strcmp(name, "proxy.config.log.logfile_dir") || !strcmp(name, 
"proxy.config.plugin.plugin_dir"))
   return true;
diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index 8e5f0f4..bde8602 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -53,22 +53,25 @@ static std::string runroot_file = {};
 // the function for the checking of the yaml file in the passed in path
 // if found return the path to the yaml file, if not return empty string.
 static std::string
-get_yaml_path(const std::string &path)
+get_yaml_path(const std::string &path, bool json)
 {
-  std::ifstream check_file;
+  std::string yaml_file;
   if (ink_file_is_directory(path.c_str())) {
-std::string yaml_path = Layout::relative_to(path, "runroot_path.yml");
-check_file.open(yaml_path);
-if (check_file.good()) {
-  return yaml_path;
-}
+yaml_file = Layout::relative_to(path, "runroot_path.yml");
   } else {
-check_file.open(path);
-if (check_file.good() && path.substr(path.find_last_of("/") + 1) == 
"runroot_path.yml") {
-  return path;
+if (path.substr(path.find_last_of("/") + 1) == "runroot_path.yml") {
+  yaml_file = path;
 }
   }
-  return {};
+  std::ifstream check_file;
+  check_file.open(yaml_file);
+  if (!check_file.good()) {
+if (!json) {
+  ink_warning("Unable to access runroot: '%s' - %s", yaml_file.c_str(), 
strerror(errno));
+}
+return {};
+  }
+  return yaml_file;
 }
 
 // the function for the checking of the yaml file in passed in directory or 
parent directory
@@ -86,8 +89,10 @@ get_parent_yaml_path(const std::string &path)
 if (whole_path.empty()) {
   return {};
 }
-std::string yaml_file = get_yaml_path(whole_path);
-if (!yaml_file.empty()) {
+std::ifstream check_file;
+std::string yaml_file = Layout::relative_to(whole_path, 
"runroot_path.yml");
+check_file.open(yaml_file);
+if (check_file.good()) {
   return yaml_file;
 }
 whole_path = whole_path.substr(0, whole_path.find_last_of("/"));
@@ -120,34 +125,26 @@ runroot_handler(const char **argv, bool json)
   if (!arg.empty() && arg != prefix) {
 // 1. pass in path
 prefix += "=";
-path = get_yaml_path(arg.substr(prefix.size(), arg.size() - 1));
+path = get_yaml_path(arg.substr(prefix.size(), arg.size() - 1), json);
 if (!path.empty()) {
   if (!json) {
 ink_notice("using command line path as RUNROOT");
   }
   runroot_file = path;
   return;
-} else {
-  if (!json) {
-ink_warning("bad RUNROOT passed in");
-  }
 }
   }
 
   // 2. check Environment variable
   char *env_val = getenv("TS_RUNROOT");
   if (env_val) {
-path = get_yaml_path(env_val);
+path = get_yaml_path(env_val, json);
 if (!path.empty()) {
   runroot_file = path;
   if (!json) {
 ink_notice("using the environment variable TS_RUNROOT");
   }
   return;
-} else {
-  if (!json) {
-ink_warning("bad Environment var: $TS_RUNROOT");
-  }
 }
   }
 
@@ -248,8 +245,8 @@ check_runroot()
   return runroot_map(runroot_file);
 }
 
-bool
-use_runroot()
+std::string_view
+get_runroot()
 {
-  return !runroot_file.empty();
+  return runroot_file;
 }
diff --git a/lib/t

[trafficserver] branch 8.0.x updated: Avoid cert callback if no verification is requested.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 9595a1b  Avoid cert callback if no verification is requested.
9595a1b is described below

commit 9595a1b3d0afc45bc383f155dad698aba9b5f493
Author: Susan Hinrichs 
AuthorDate: Tue Jul 3 10:04:02 2018 -0500

Avoid cert callback if no verification is requested.

(cherry picked from commit 6d27764b64ae30275ab7ad750dd0a54ff8050df7)
---
 iocore/net/SSLNetVConnection.cc | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index d4317b9..6cb133d 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -1016,7 +1016,15 @@ SSLNetVConnection::sslStartHandShake(int event, int &err)
 SSLErrorVC(this, "failed to create SSL client session");
 return EVENT_ERROR;
   }
-  SSL_set_verify(this->ssl, clientVerify ? SSL_VERIFY_PEER : 
SSL_VERIFY_NONE, verify_callback);
+  int verify_op;
+  if (clientVerify) {
+verify_op = SSL_VERIFY_PEER;
+SSL_set_verify(this->ssl, verify_op, verify_callback);
+  } else {
+// Don't bother to set the verify callback if no verification is 
required
+verify_op = SSL_VERIFY_NONE;
+SSL_set_verify(this->ssl, verify_op, nullptr);
+  }
 
   if (this->options.sni_servername) {
 if (SSL_set_tlsext_host_name(this->ssl, this->options.sni_servername)) 
{



[trafficserver] branch 8.0.x updated: fix the number of started threads of certain type.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 9734b7c  fix the number of started threads of certain type.
9734b7c is described below

commit 9734b7cba283f55b742151eb171a771cbbc1ad67
Author: Oknet Xu 
AuthorDate: Fri Aug 10 00:46:30 2018 +0800

fix the number of started threads of certain type.

(cherry picked from commit 5642ab204d5ddc1145a0d567a3044eabee539e68)
---
 iocore/eventsystem/UnixEventProcessor.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iocore/eventsystem/UnixEventProcessor.cc 
b/iocore/eventsystem/UnixEventProcessor.cc
index d2e86c7..af38b8a 100644
--- a/iocore/eventsystem/UnixEventProcessor.cc
+++ b/iocore/eventsystem/UnixEventProcessor.cc
@@ -394,8 +394,8 @@ EventProcessor::initThreadState(EThread *t)
 {
   // Run all thread type initialization continuations that match the event 
types for this thread.
   for (int i = 0; i < MAX_EVENT_TYPES; ++i) {
-thread_group[i]._started++;
 if (t->is_event_type(i)) { // that event type done here, roll thread start 
events of that type.
+  ++thread_group[i]._started;
   // To avoid race conditions on the event in the spawn queue, create a 
local one to actually send.
   // Use the spawn queue event as a read only model.
   Event *nev = eventAllocator.alloc();



[trafficserver] branch 8.0.x updated: Added clear_event function to cancel inactive event before marking it as nullptr

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 7d33ac8  Added clear_event function to cancel inactive event before 
marking it as nullptr
7d33ac8 is described below

commit 7d33ac8cb89bbcb074e0910290bb8d1301e4196e
Author: dyrock 
AuthorDate: Tue Aug 7 18:59:32 2018 +

Added clear_event function to cancel inactive event before marking it as 
nullptr

(cherry picked from commit cb784429ec035f4f669bc2d62ad94d26b58c825d)
---
 proxy/PluginVC.cc | 23 ---
 proxy/PluginVC.h  |  4 
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index 55ea62f..3c99653 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -208,9 +208,6 @@ PluginVC::main_handler(int event, void *data)
   } else if (call_event == inactive_event) {
 if (inactive_timeout_at && inactive_timeout_at < Thread::get_hrtime()) {
   process_timeout(&inactive_event, VC_EVENT_INACTIVITY_TIMEOUT);
-  if (nullptr == inactive_event) {
-call_event->cancel();
-  }
 }
   } else {
 if (call_event == sm_lock_retry_event) {
@@ -748,7 +745,7 @@ PluginVC::process_timeout(Event **e, int event_to_send)
   if (closed) {
 // already closed, ignore the timeout event
 // to avoid handle_event asserting use-after-free
-*e = nullptr;
+clear_event(e);
 return;
   }
 
@@ -761,7 +758,7 @@ PluginVC::process_timeout(Event **e, int event_to_send)
   }
   return;
 }
-*e = nullptr;
+clear_event(e);
 read_state.vio.cont->handleEvent(event_to_send, &read_state.vio);
   } else if (write_state.vio.op == VIO::WRITE && !write_state.shutdown && 
write_state.vio.ntodo() > 0) {
 MUTEX_TRY_LOCK(lock, write_state.vio.mutex, (*e)->ethread);
@@ -772,11 +769,23 @@ PluginVC::process_timeout(Event **e, int event_to_send)
   }
   return;
 }
-*e = nullptr;
+clear_event(e);
 write_state.vio.cont->handleEvent(event_to_send, &write_state.vio);
   } else {
-*e = nullptr;
+clear_event(e);
+  }
+}
+
+void
+PluginVC::clear_event(Event **e)
+{
+  if (e == nullptr || *e == nullptr)
+return;
+  if (*e == inactive_event) {
+inactive_event->cancel();
+inactive_timeout_at = 0;
   }
+  *e = nullptr;
 }
 
 void
diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h
index 96aba0f..7ce9a85 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -151,6 +151,10 @@ private:
   void process_close();
   void process_timeout(Event **e, int event_to_send);
 
+  // Clear the Event pointer pointed to by e
+  // Cancel the action first if it is a periodic event
+  void clear_event(Event **e);
+
   void setup_event_cb(ink_hrtime in, Event **e_ptr);
 
   void update_inactive_time();



[trafficserver] branch 8.0.x updated: Fix logic to support ASYNC_pause_job

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 2c0100b  Fix logic to support ASYNC_pause_job
2c0100b is described below

commit 2c0100b95717a48fcbe76b58cb91e1f56da3
Author: Susan Hinrichs 
AuthorDate: Fri Jul 27 15:53:31 2018 +

Fix logic to support ASYNC_pause_job

(cherry picked from commit beb56189c216fa5510f8004de687b19a465765ab)
---
 iocore/net/P_SSLNetVConnection.h |  3 ---
 iocore/net/SSLNetVConnection.cc  | 40 ++--
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h
index 271b718..b3b22c4 100644
--- a/iocore/net/P_SSLNetVConnection.h
+++ b/iocore/net/P_SSLNetVConnection.h
@@ -352,9 +352,6 @@ private:
   bool sslTrace= false;
   bool SNIMapping  = false;
   int64_t redoWriteSize= 0;
-#ifdef SSL_MODE_ASYNC
-  EventIO signalep;
-#endif
 };
 
 typedef int (SSLNetVConnection::*SSLNetVConnHandler)(int, void *);
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 6cb133d..eb78db2 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -66,6 +66,7 @@ void SSL_set0_rbio(SSL *ssl, BIO *rbio);
 #define SSL_HANDSHAKE_WANT_CONNECT 9
 #define SSL_WRITE_WOULD_BLOCK 10
 #define SSL_WAIT_FOR_HOOK 11
+#define SSL_WAIT_FOR_ASYNC 12
 
 ClassAllocator sslNetVCAllocator("sslNetVCAllocator");
 
@@ -577,7 +578,7 @@ SSLNetVConnection::net_read_io(NetHandler *nh, EThread 
*lthread)
   nh->read_ready_list.in_or_enqueue(this);
 }
   }
-} else if (ret == SSL_WAIT_FOR_HOOK) {
+} else if (ret == SSL_WAIT_FOR_HOOK || ret == SSL_WAIT_FOR_ASYNC) {
   // avoid readReschedule - done when the plugin calls us back to reenable
 } else {
   readReschedule(nh);
@@ -1129,26 +1130,37 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err)
 #endif
   ssl_error_t ssl_error = SSLAccept(ssl);
 #if TS_USE_TLS_ASYNC
-  if (ssl_error == SSL_ERROR_WANT_ASYNC && this->signalep.type == 0) {
+  if (ssl_error == SSL_ERROR_WANT_ASYNC) {
 size_t numfds;
 OSSL_ASYNC_FD waitfd;
 // Set up the epoll entry for the signalling
 if (SSL_get_all_async_fds(ssl, &waitfd, &numfds) && numfds > 0) {
+  // Temporarily disable regular net
+  read_disable(nh, this);
+  this->ep.stop(); // Modify used in read_disable doesn't work for edge 
triggered epol
+  // Have to have the read NetState enabled because we are using it for 
the signal vc
+  read.enabled = true;
+  write_disable(nh, this);
   PollDescriptor *pd = get_PollDescriptor(this_ethread());
-  this->signalep.start(pd, waitfd, this, EVENTIO_READ);
-  this->signalep.type = EVENTIO_READWRITE_VC;
+  this->ep.start(pd, waitfd, this, EVENTIO_READ);
+  this->ep.type = EVENTIO_READWRITE_VC;
 }
-  } else
-#endif
-if (ssl_error == SSL_ERROR_NONE || ssl_error == SSL_ERROR_SSL) {
-#if TS_USE_TLS_ASYNC
-if (SSLConfigParams::async_handshake_enabled) {
-  // Clean up the epoll entry for signalling
-  SSL_clear_mode(ssl, SSL_MODE_ASYNC);
-  this->signalep.stop();
+  } else if (SSLConfigParams::async_handshake_enabled) {
+// Clean up the epoll entry for signalling
+SSL_clear_mode(ssl, SSL_MODE_ASYNC);
+this->ep.stop();
+// Rectivate the socket, ready to rock
+PollDescriptor *pd = get_PollDescriptor(this_ethread());
+this->ep.start(
+  pd, this,
+  EVENTIO_READ |
+EVENTIO_WRITE); // Again we must muck with the eventloop directly 
because of limits with these methods and edge trigger
+if (ssl_error == SSL_ERROR_WANT_READ) {
+  this->reenable(&read.vio);
+  this->read.triggered = 1;
 }
-#endif
   }
+#endif
   bool trace = getSSLTrace();
 
   if (ssl_error != SSL_ERROR_NONE) {
@@ -1271,7 +1283,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err)
 #if TS_USE_TLS_ASYNC
   case SSL_ERROR_WANT_ASYNC:
 TraceIn(trace, get_remote_addr(), get_remote_port(), "SSL server handshake 
ERROR_WANT_ASYNC");
-return EVENT_CONT;
+return SSL_WAIT_FOR_ASYNC;
 #endif
 
   case SSL_ERROR_WANT_ACCEPT:



[trafficserver] branch 8.0.x updated: make sure len is smaller than MAX_ENTRY before we use it as the index

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 40f80dc  make sure len is smaller than MAX_ENTRY before we use it as 
the index
40f80dc is described below

commit 40f80dc800ff97377cf32f12e26551b540f36eec
Author: Fei Deng 
AuthorDate: Thu Aug 9 10:54:39 2018 -0500

make sure len is smaller than MAX_ENTRY before we use it as the index

(cherry picked from commit 6f5817b7002c9247c3f219db89afd7f583cbc1ec)
---
 proxy/logging/LogObject.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index c953f39..50385e5 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -511,14 +511,14 @@ LogObject::va_log(LogAccess *lad, const char *fmt, 
va_list ap)
 
   if (this->m_flags & LOG_OBJECT_FMT_TIMESTAMP) {
 len = LogUtils::timestamp_to_str(LogUtils::timestamp(), entry, MAX_ENTRY);
-if (len <= 0) {
+if (unlikely(len <= 0 || len >= MAX_ENTRY)) {
   return Log::FAIL;
 }
 
 // Add a space after the timestamp
 entry[len++] = ' ';
 
-if (len >= MAX_ENTRY) {
+if (unlikely(len >= MAX_ENTRY)) {
   return Log::FAIL;
 }
   }



[trafficserver] branch 7.1.x updated: make sure len is smaller than MAX_ENTRY before we use it as the index

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
 new 1447240  make sure len is smaller than MAX_ENTRY before we use it as 
the index
1447240 is described below

commit 14472405258aaca8b36c0f176953cd77afc2e5e2
Author: Fei Deng 
AuthorDate: Thu Aug 9 10:54:39 2018 -0500

make sure len is smaller than MAX_ENTRY before we use it as the index

(cherry picked from commit 6f5817b7002c9247c3f219db89afd7f583cbc1ec)
---
 proxy/logging/LogObject.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index 6878210..7133f63 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -493,14 +493,14 @@ LogObject::va_log(LogAccess *lad, const char *fmt, 
va_list ap)
 
   if (this->m_flags & LOG_OBJECT_FMT_TIMESTAMP) {
 len = LogUtils::timestamp_to_str(LogUtils::timestamp(), entry, MAX_ENTRY);
-if (len <= 0) {
+if (unlikely(len <= 0 || len >= MAX_ENTRY)) {
   return Log::FAIL;
 }
 
 // Add a space after the timestamp
 entry[len++] = ' ';
 
-if (len >= MAX_ENTRY) {
+if (unlikely(len >= MAX_ENTRY)) {
   return Log::FAIL;
 }
   }



[trafficserver] 02/03: BufferWriter: Add OptionalAffix support for optionally printing strings. Update the documenation.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit c25f554a9c1c250305e48bd0fdc16cfd2ce1f22c
Author: Alan M. Carroll 
AuthorDate: Mon Jul 2 20:46:56 2018 -0500

BufferWriter: Add OptionalAffix support for optionally printing strings.
Update the documenation.

(cherry picked from commit 59d1c368e94c7c3f2c1ccf44b69f65bdc3158f74)
---
 .../internal-libraries/buffer-writer.en.rst| 92 ++
 lib/ts/BufferWriterFormat.cc   |  6 ++
 lib/ts/bwf_std_format.h| 25 ++
 3 files changed, 109 insertions(+), 14 deletions(-)

diff --git a/doc/developer-guide/internal-libraries/buffer-writer.en.rst 
b/doc/developer-guide/internal-libraries/buffer-writer.en.rst
index 4f7a416..adbf871 100644
--- a/doc/developer-guide/internal-libraries/buffer-writer.en.rst
+++ b/doc/developer-guide/internal-libraries/buffer-writer.en.rst
@@ -638,7 +638,9 @@ uses the :code:`std::string` overload for :func:`bwprint` 
would look like ::
}
 
 This gathers the argument (generally references to the arguments) in to a 
single tuple which is then
-passed by reference, to avoid restacking the arguments for every nested 
function call.
+passed by reference, to avoid restacking the arguments for every nested 
function call. In essence the
+arguments are put on the stack (inside the tuple) once and a reference to that 
stack is passed to
+nested functions.
 
 Specialized Types
 -
@@ -715,46 +717,108 @@ but can be overloaded to produce different (wrapper 
class based) output. The cla
 such as the descriptive string for the value. To do this the format wrapper 
class :code:`ts::bwf::Errno`
 is provided. Using it is simple::
 
-w.print("File not open - {}", ts::bwf::Errno(errno));
+   w.print("File not open - {}", ts::bwf::Errno(errno));
 
 which will produce output that looks like
 
-"File not open - EACCES: Permission denied [13]"
+   "File not open - EACCES: Permission denied [13]"
 
 For :code:`errno` this is handy in another way as :code:`ts::bwf::Errno` will 
preserve the value of
 :code:`errno` across other calls that might change it. E.g.::
 
-ts::bwf::Errno last_err(errno);
-// some other code generating diagnostics that might tweak errno.
-w.print("File not open - {}", last_err);
+   ts::bwf::Errno last_err(errno);
+   // some other code generating diagnostics that might tweak errno.
+   w.print("File not open - {}", last_err);
+
+This can also be useful for user defined data types. For instance, in the 
HostDB the type of the entry
+is printed in multiple places and each time this code is repeated ::
+
+  "%s%s %s", r->round_robin ? "Round-Robin" : "",
+ r->reverse_dns ? "Reverse DNS" : "", r->is_srv ? "SRV" : "DNS"
+
+This could be wrapped in a class, :code:`HostDBType` such as ::
+
+   struct HostDBType {
+  HostDBInfo* _r { nullptr };
+  HostDBType(r) : _r(r) {}
+   };
+
+Then define a formatter for the wrapper ::
+
+   BufferWriter& bwformat(BufferWriter& w, BWFSpec const& spec, HostDBType 
const& wrap) {
+ return w.print("{}{} {}", wrap._r->round_robin ? "Round-Robin" : "",
+r->reverse_dns ? "Reverse DNS" : "",
+r->is_srv ? "SRV" : "DNS");
+   }
+
+Now this can be output elsewhere with just
+
+   w.print("{}", HostDBType(r));
+
+If this is used multiple places, this is cleaner and more robust as it can be 
updated everywhere with a
+change in a single code location.
 
 These are the existing format classes in header file ``bfw_std_format.h``. All 
are in the :code:`ts::bwf` namespace.
 
 .. class:: Errno
 
-Formating for :code:`errno`.
+   Formating for :code:`errno`.
 
-.. function:: Errno(int errno)
+   .. function:: Errno(int errno)
 
 .. class:: Date
 
-Date formatting in the :code:`strftime` style.
+   Date formatting in the :code:`strftime` style.
 
-.. function:: Date(time_t epoch, std::string_view fmt = "%Y %b %d 
%H:%M:%S")
+   .. function:: Date(time_t epoch, std::string_view fmt = "%Y %b %d %H:%M:%S")
 
-:arg:`epoch` is the time to print. :arg:`fmt` is the format for 
printing which is identical to that of `strftime 
`__. The default format looks like "2018 
Jun 08 13:55:37".
+  :arg:`epoch` is the time to print. :arg:`fmt` is the format for printing 
which is identical to
+  that of `strftime `__. The default 
format looks like
+  "2018 Jun 08 13:55:37".
 
-.. function:: Date(std::string_view fmt = "%Y %b %d %H:%M:%S")
+   .. function:: Date(std::string_view fmt = "%Y %b %d %H:%M:%S")
 
- As previous except the epoch is the current epoch at the time the 
constructor is invoked. Therefore if the current time is to be printed the 
default constructor can be used.
+  As previous except the epoch is the current

[trafficserver] 01/03: BufferWriter: Some minor cleanups. Clean up use of std::literal, add bwf::Errno default constructor, move Date format to explicit default.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit d3ab5b50a5d0897459f04b45b1a18aff0deef7fa
Author: Alan M. Carroll 
AuthorDate: Mon Jul 2 20:44:17 2018 -0500

BufferWriter: Some minor cleanups.
Clean up use of std::literal, add bwf::Errno default constructor, move Date 
format to explicit default.

(cherry picked from commit b28833b7cce7a77fc03ab80811ae3247b3cf49af)
---
 lib/ts/BufferWriter.h   |  5 +++--
 lib/ts/bwf_std_format.h | 23 +++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/lib/ts/BufferWriter.h b/lib/ts/BufferWriter.h
index b1c4c9b..b459ee1 100644
--- a/lib/ts/BufferWriter.h
+++ b/lib/ts/BufferWriter.h
@@ -35,8 +35,6 @@
 #include 
 #include 
 
-using namespace std::literals;
-
 namespace ts
 {
 /** Base (abstract) class for concrete buffer writers.
@@ -611,6 +609,7 @@ template 
 BufferWriter &
 BufferWriter::printv(TextView fmt, std::tuple const &args)
 {
+  using namespace std::literals;
   static constexpr int N = sizeof...(Args); // used as loop limit
   static const auto fa   = 
bw_fmt::Get_Arg_Formatter_Array(std::index_sequence_for{});
   int arg_idx= 0; // the next argument index to be processed.
@@ -671,6 +670,7 @@ template 
 BufferWriter &
 BufferWriter::printv(BWFormat const &fmt, std::tuple const &args)
 {
+  using namespace std::literals;
   static constexpr int N = sizeof...(Args);
   static const auto fa   = 
bw_fmt::Get_Arg_Formatter_Array(std::index_sequence_for{});
 
@@ -795,6 +795,7 @@ bwformat(BufferWriter &w, BWFSpec const &, char c)
 inline BufferWriter &
 bwformat(BufferWriter &w, BWFSpec const &spec, bool f)
 {
+  using namespace std::literals;
   if ('s' == spec._type) {
 w.write(f ? "true"sv : "false"sv);
   } else if ('S' == spec._type) {
diff --git a/lib/ts/bwf_std_format.h b/lib/ts/bwf_std_format.h
index 60776c4..aee70f6 100644
--- a/lib/ts/bwf_std_format.h
+++ b/lib/ts/bwf_std_format.h
@@ -25,12 +25,14 @@
 
 #include 
 #include 
+#include 
+#include 
 
 namespace std
 {
 template 
 ts::BufferWriter &
-bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, std::atomic const &v)
+bwformat(ts::BufferWriter &w, ts::BWFSpec const &spec, atomic const &v)
 {
   return ts::bwformat(w, spec, v.load());
 }
@@ -40,17 +42,30 @@ namespace ts
 {
 namespace bwf
 {
+  using namespace std::literals; // enable ""sv
+
+  /** Format wrapper for @c errno.
+   * This stores a copy of the argument or @c errno if an argument isn't 
provided. The output
+   * is then formatted with the short, long, and numeric value of @c errno. If 
the format specifier
+   * is type 'd' then just the numeric value is printed.
+   */
   struct Errno {
 int _e;
-explicit Errno(int e) : _e(e) {}
+explicit Errno(int e = errno) : _e(e) {}
   };
 
+  /** Format wrapper for time stamps.
+   * If the time isn't provided, the current epoch time is used. If the format 
string isn't
+   * provided a format like "2017 Jun 29 14:11:29" is used.
+   */
   struct Date {
+static constexpr std::string_view DEFAULT_FORMAT{"%Y %b %d %H:%M:%S"_sv};
 time_t _epoch;
 std::string_view _fmt;
-Date(time_t t, std::string_view fmt = "%Y %b %d %H:%M:%S"sv) : _epoch(t), 
_fmt(fmt) {}
-Date(std::string_view fmt = "%Y %b %d %H:%M:%S"sv);
+Date(time_t t, std::string_view fmt = DEFAULT_FORMAT) : _epoch(t), 
_fmt(fmt) {}
+Date(std::string_view fmt = DEFAULT_FORMAT);
   };
+
 } // namespace bwf
 
 BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, bwf::Errno const 
&e);



[trafficserver] 03/03: TextView: Add constexpr literal constructor for std::string_view.

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 22b1ff6c17e98e5cb9f447685730b8618e9fc007
Author: Alan M. Carroll 
AuthorDate: Mon Jul 2 20:34:08 2018 -0500

TextView: Add constexpr literal constructor for std::string_view.

(cherry picked from commit 0225210345ec575c4ddbe37ed011e16f6e61738e)
---
 lib/ts/TextView.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/ts/TextView.h b/lib/ts/TextView.h
index a1a688f..d4494cd 100644
--- a/lib/ts/TextView.h
+++ b/lib/ts/TextView.h
@@ -1018,3 +1018,13 @@ namespace std
 {
 ostream &operator<<(ostream &os, const ts::TextView &b);
 }
+
+// @c constexpr literal constructor for @c std::string_view
+// For unknown reasons, this enables creating @c constexpr constructs using @c 
std::string_view while the standard
+// one (""sv) does not.
+// I couldn't think of any better place to put this, so it's here. At least @c 
TextView is strongly related
+// to @c std::string_view.
+constexpr std::string_view operator"" _sv(const char *s, size_t n)
+{
+  return {s, n};
+}



[trafficserver] branch 8.0.x updated (40f80dc -> 22b1ff6)

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a change to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from 40f80dc  make sure len is smaller than MAX_ENTRY before we use it as 
the index
 new d3ab5b5  BufferWriter: Some minor cleanups. Clean up use of 
std::literal, add bwf::Errno default constructor, move Date format to explicit 
default.
 new c25f554  BufferWriter: Add OptionalAffix support for optionally 
printing strings. Update the documenation.
 new 22b1ff6  TextView: Add constexpr literal constructor for 
std::string_view.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../internal-libraries/buffer-writer.en.rst| 92 ++
 lib/ts/BufferWriter.h  |  5 +-
 lib/ts/BufferWriterFormat.cc   |  6 ++
 lib/ts/TextView.h  | 10 +++
 lib/ts/bwf_std_format.h| 48 ++-
 5 files changed, 141 insertions(+), 20 deletions(-)



[trafficserver] branch 8.0.x updated: Updated Changelog

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new dafcea0  Updated Changelog
dafcea0 is described below

commit dafcea0eb582363ca934290e4b310e8600c5cc38
Author: Leif Hedstrom 
AuthorDate: Mon Aug 13 14:15:05 2018 -0600

Updated Changelog
---
 CHANGELOG-8.0.0 | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/CHANGELOG-8.0.0 b/CHANGELOG-8.0.0
index 377992a..6b1bb1b 100644
--- a/CHANGELOG-8.0.0
+++ b/CHANGELOG-8.0.0
@@ -1134,9 +1134,14 @@ Changes with Apache Traffic Server 8.0.0
   #3892 - SNI based IP_ALLOW
   #3893 - Fix coredump issue when calling ts.fetch
   #3894 - Sending stdout and stderr to traffic.out
+  #3895 - Add optional feature to use cache-key-url for parent selection
+  #3898 - Runroot: Add an option to specify copy style and reformat the doc
   #3899 - Add a --reason tag option to the host subcommand
   #3902 - Recognize openssl engines for key loading.
+  #3903 - traffic_manager: Fix error, clean up argument handling.
+  #3908 - BWF: Add "OptionalAffix", clean up some minor BWF wrapper class 
issues.
   #3909 - Fixes detection of OpenSSL's OCSP APIs
+  #3912 - Avoid cert callback if no verification is requested.
   #3915 - Doc: Fix build errors in logging.
   #3916 - Fixes OCSP warnings when cert has no OCSP URI attached to it
   #3917 - Converts remaining header files to #pragma once
@@ -1144,6 +1149,7 @@ Changes with Apache Traffic Server 8.0.0
   #3919 - Clarifies alternate # selected in log output
   #3920 - CPPApi Intercept Plugin: Changed destroy logic
   #3929 - Log lock cleanup
+  #3932 - Runroot: add new option to specify layout during creating
   #3933 - Removed assignment of unused variable
   #3934 - cachekey: running as global plugin
   #3935 - Link with libluajit for the lua plugin
@@ -1152,6 +1158,7 @@ Changes with Apache Traffic Server 8.0.0
   #3946 - Fix bug on loading speed up for lua script
   #3948 - Enhances detection of luajit
   #3949 - Fixed http/2 issue with Http2Stream being updated after it was 
destroyed
+  #3950 - access_control plugin
   #3952 - ASAN: stack-use-after-scope
   #3959 - Cleans up brotli compiler and linker flags
   #3960 - Cleans up LDADDs in traffic_server
@@ -1159,12 +1166,15 @@ Changes with Apache Traffic Server 8.0.0
   #3969 - Clearout shutdown_cont_event when the event has been processed
   #3970 - Remove Http2ConnectionState::continued_buffer
   #3983 - Fixes some var-args missing va_start/end
+  #3994 - Runroot: Add feature to use runroot by providing yaml file
   #4000 - TS-4765: Removes previously deprecated cqbl and pqbl log tags
   #4001 - Removes old commented-out code
   #4002 - Fixes spelling
   #4004 - Dockerfile for CentOS/Fedora, i.e. yum dependencies
   #4011 - Modifies init script to add start/reload hooks
   #4014 - fix outputlog, diagslog rolling size overflow
+  #4021 - Runroot: pass runroot down from manager and error message update
+  #4024 - Fix logic to support ASYNC_pause_job
   #4025 - Removes non-FS ciphers to make SSLLabs not warn on weak ciphers
   #4027 - Fixes ticket loading from filesystems without a mtime
   #4035 - Fixing copy paste error in SNI yaml parsing
@@ -1177,8 +1187,12 @@ Changes with Apache Traffic Server 8.0.0
   #4068 - Cleans up README and sample config for compress plugin
   #4070 - Renames TSHttpTxnSetHttpRetStatus to TSHttpTxnStatusSet
   #4073 - Fix Http/2 priority crashes.
+  #4074 - Cancel inactive event before marking it as nullptr in 
PluginVC::process_timeout()
   #4076 - traffic_manager: fix --tsArgs to work.
   #4078 - In conf_remap plugin, print name of non-existent or non-overriddable 
…
   #4081 - Fix typo in header_normalize plugin.
   #4083 - Links server_push_preload plugin against libatscppapi
+  #4088 - Make sure len is smaller than MAX_ENTRY before we use it as the index
+  #4090 - fix the number of started threads of certain type.
   #4091 - logstats conditionally disable format check
+  #4093 - Fixes the renamed RenameTSHttpTxnSetHttpRetStatus() API



[trafficserver] branch master updated: Prefetch plugin

2018-08-13 Thread gancho
This is an automated email from the ASF dual-hosted git repository.

gancho 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 18e67bd  Prefetch plugin
18e67bd is described below

commit 18e67bd9e9790543e2872741d48b61571ef5408c
Author: Gancho Tenev 
AuthorDate: Sat Jun 30 00:48:24 2018 -0700

Prefetch plugin

The purpose of the plugin is to increase the cache-hit ratio
for a sequence of objects which URL paths follow a common pattern.
---
 doc/admin-guide/plugins/index.en.rst   |   1 +
 doc/admin-guide/plugins/prefetch.en.rst| 278 
 .../images/admin/prefetch_plugin_deployment.png| Bin 0 -> 222757 bytes
 plugins/Makefile.am|   1 +
 plugins/experimental/prefetch/Makefile.inc |  28 +
 plugins/experimental/prefetch/README.md|   8 +
 plugins/experimental/prefetch/common.cc|  59 ++
 plugins/experimental/prefetch/common.h |  68 ++
 plugins/experimental/prefetch/configs.cc   | 172 +
 plugins/experimental/prefetch/configs.h| 202 ++
 plugins/experimental/prefetch/fetch.cc | 739 
 plugins/experimental/prefetch/fetch.h  | 202 ++
 plugins/experimental/prefetch/fetch_policy.cc  |  57 ++
 plugins/experimental/prefetch/fetch_policy.h   |  66 ++
 plugins/experimental/prefetch/fetch_policy_lru.cc  | 141 
 plugins/experimental/prefetch/fetch_policy_lru.h   | 105 +++
 .../experimental/prefetch/fetch_policy_simple.cc   |  80 +++
 .../experimental/prefetch/fetch_policy_simple.h|  46 ++
 plugins/experimental/prefetch/headers.cc   | 213 ++
 plugins/experimental/prefetch/headers.h|  31 +
 plugins/experimental/prefetch/pattern.cc   | 463 +
 plugins/experimental/prefetch/pattern.h|  92 +++
 plugins/experimental/prefetch/plugin.cc| 751 +
 23 files changed, 3803 insertions(+)

diff --git a/doc/admin-guide/plugins/index.en.rst 
b/doc/admin-guide/plugins/index.en.rst
index 566eecf..2a37ea6 100644
--- a/doc/admin-guide/plugins/index.en.rst
+++ b/doc/admin-guide/plugins/index.en.rst
@@ -161,6 +161,7 @@ directory of the |TS| source tree. Experimental plugins can 
be compiled by passi
Stale While Revalidate 
System Statistics 
WebP Transform 
+   Prefetch 
 
 :doc:`Access Control `
Access control plugin that handles various access control use-cases.
diff --git a/doc/admin-guide/plugins/prefetch.en.rst 
b/doc/admin-guide/plugins/prefetch.en.rst
new file mode 100644
index 000..93a7e3c
--- /dev/null
+++ b/doc/admin-guide/plugins/prefetch.en.rst
@@ -0,0 +1,278 @@
+.. 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
+
+.. _admin-plugins-prefetch:
+
+
+Prefetch Plugin
+***
+
+Description
+===
+
+The purpose of the plugin is to increase the cache-hit ratio for a sequence of
+objects which URL paths follow a common pattern.
+
+On every **incoming** URL request, the plugin can decide to pre-fetch the
+**next object** or more objects based on the common URL path pattern and a
+pre-defined pre-fetch policy.
+
+Currently, most HLS video urls follow a predictable pattern, with most URLs
+containing a segment number. Since the segments are ~10s of content, the normal
+usage pattern is to fetch the incremental segment every few seconds. The CDN
+has its best chance of delivering a good user experience if the requests are
+served from cache. Since we can predict the **next object** fetched, we should 
be
+able to dramatically increase the chance of it being a cache hit.
+
+This is primarily useful for:
+
+* less popular content. Popular movies' segments are constantly being refreshed
+  in cache by user requests. Less popular content is less likely to be in 
cache.
+* device failures. There can be a significant time gap between a seeding 
request
+  and the user request. During this time, devices can fail, which cause cache
+  misses. The time gap between the plugin's request and the user's request can 
b

[trafficserver] branch 8.0.x updated: Prefetch plugin

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 10dce66  Prefetch plugin
10dce66 is described below

commit 10dce66501294b297f376dcbdb4bc75003df97d5
Author: Gancho Tenev 
AuthorDate: Sat Jun 30 00:48:24 2018 -0700

Prefetch plugin

The purpose of the plugin is to increase the cache-hit ratio
for a sequence of objects which URL paths follow a common pattern.

(cherry picked from commit 18e67bd9e9790543e2872741d48b61571ef5408c)
---
 doc/admin-guide/plugins/index.en.rst   |   1 +
 doc/admin-guide/plugins/prefetch.en.rst| 278 
 .../images/admin/prefetch_plugin_deployment.png| Bin 0 -> 222757 bytes
 plugins/Makefile.am|   1 +
 plugins/experimental/prefetch/Makefile.inc |  28 +
 plugins/experimental/prefetch/README.md|   8 +
 plugins/experimental/prefetch/common.cc|  59 ++
 plugins/experimental/prefetch/common.h |  68 ++
 plugins/experimental/prefetch/configs.cc   | 172 +
 plugins/experimental/prefetch/configs.h| 202 ++
 plugins/experimental/prefetch/fetch.cc | 739 
 plugins/experimental/prefetch/fetch.h  | 202 ++
 plugins/experimental/prefetch/fetch_policy.cc  |  57 ++
 plugins/experimental/prefetch/fetch_policy.h   |  66 ++
 plugins/experimental/prefetch/fetch_policy_lru.cc  | 141 
 plugins/experimental/prefetch/fetch_policy_lru.h   | 105 +++
 .../experimental/prefetch/fetch_policy_simple.cc   |  80 +++
 .../experimental/prefetch/fetch_policy_simple.h|  46 ++
 plugins/experimental/prefetch/headers.cc   | 213 ++
 plugins/experimental/prefetch/headers.h|  31 +
 plugins/experimental/prefetch/pattern.cc   | 463 +
 plugins/experimental/prefetch/pattern.h|  92 +++
 plugins/experimental/prefetch/plugin.cc| 751 +
 23 files changed, 3803 insertions(+)

diff --git a/doc/admin-guide/plugins/index.en.rst 
b/doc/admin-guide/plugins/index.en.rst
index 9a61b2e..0b097f3 100644
--- a/doc/admin-guide/plugins/index.en.rst
+++ b/doc/admin-guide/plugins/index.en.rst
@@ -160,6 +160,7 @@ directory of the |TS| source tree. Experimental plugins can 
be compiled by passi
Stale While Revalidate 
System Statistics 
WebP Transform 
+   Prefetch 
 
 :doc:`Access Control `
Access control plugin that handles various access control use-cases.
diff --git a/doc/admin-guide/plugins/prefetch.en.rst 
b/doc/admin-guide/plugins/prefetch.en.rst
new file mode 100644
index 000..93a7e3c
--- /dev/null
+++ b/doc/admin-guide/plugins/prefetch.en.rst
@@ -0,0 +1,278 @@
+.. 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
+
+.. _admin-plugins-prefetch:
+
+
+Prefetch Plugin
+***
+
+Description
+===
+
+The purpose of the plugin is to increase the cache-hit ratio for a sequence of
+objects which URL paths follow a common pattern.
+
+On every **incoming** URL request, the plugin can decide to pre-fetch the
+**next object** or more objects based on the common URL path pattern and a
+pre-defined pre-fetch policy.
+
+Currently, most HLS video urls follow a predictable pattern, with most URLs
+containing a segment number. Since the segments are ~10s of content, the normal
+usage pattern is to fetch the incremental segment every few seconds. The CDN
+has its best chance of delivering a good user experience if the requests are
+served from cache. Since we can predict the **next object** fetched, we should 
be
+able to dramatically increase the chance of it being a cache hit.
+
+This is primarily useful for:
+
+* less popular content. Popular movies' segments are constantly being refreshed
+  in cache by user requests. Less popular content is less likely to be in 
cache.
+* device failures. There can be a significant time gap between a seeding 
request
+  and the user request. During this time, devices can fail, which cause cache
+  miss

[trafficserver] branch 8.0.x updated: Updated ChangeLog

2018-08-13 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/8.0.x by this push:
 new 12b3103  Updated ChangeLog
12b3103 is described below

commit 12b31038bcf419dae8665e7a461395fd8089fc21
Author: Leif Hedstrom 
AuthorDate: Mon Aug 13 14:26:44 2018 -0600

Updated ChangeLog
---
 CHANGELOG-8.0.0 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG-8.0.0 b/CHANGELOG-8.0.0
index 6b1bb1b..39b2cb0 100644
--- a/CHANGELOG-8.0.0
+++ b/CHANGELOG-8.0.0
@@ -963,6 +963,7 @@ Changes with Apache Traffic Server 8.0.0
   #3609 - Remove traffic_cop
   #3610 - Clang6: Fix garbage return value in CacheTool.cc.
   #3613 - Remove unused code
+  #3613 - Remove unused code
   #3615 - No need to walk the buckets for cache scan
   #3619 - Fix Coverity ID 1022023
   #3620 - Coverity 1021989



[trafficserver] branch master updated: cachekey: handle empty regex group captures

2018-08-13 Thread gancho
This is an automated email from the ASF dual-hosted git repository.

gancho 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 4d5790f  cachekey: handle empty regex group captures
4d5790f is described below

commit 4d5790f796c90db9b8ee245ff179a5a5f66c2608
Author: Gancho Tenev 
AuthorDate: Sat Aug 11 14:31:12 2018 -0700

cachekey: handle empty regex group captures
---
 plugins/cachekey/pattern.cc | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/plugins/cachekey/pattern.cc b/plugins/cachekey/pattern.cc
index a63fc97..319a4a3 100644
--- a/plugins/cachekey/pattern.cc
+++ b/plugins/cachekey/pattern.cc
@@ -303,6 +303,12 @@ Pattern::replace(const String &subject, String &result)
 int start = ovector[2 * replIndex];
 int length= ovector[2 * replIndex + 1] - ovector[2 * replIndex];
 
+/* Handle the case when no match / a group capture result in an empty 
string */
+if (start < 0) {
+  start  = 0;
+  length = 0;
+}
+
 String src(_replacement, _tokenOffset[i], 2);
 String dst(subject, start, length);
 



[trafficserver] branch master updated: Ensure continuation lock on read and write signal

2018-08-13 Thread shinrich
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 17d1203  Ensure continuation lock on read and write signal
17d1203 is described below

commit 17d12031bd23b8f5b047f151e5909c375d99bc5d
Author: Susan Hinrichs 
AuthorDate: Mon Aug 13 16:14:04 2018 +

Ensure continuation lock on read and write signal
---
 iocore/net/UnixNetVConnection.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index ccd620a..afc7dfb 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -78,9 +78,10 @@ net_activity(UnixNetVConnection *vc, EThread *thread)
 static inline int
 read_signal_and_update(int event, UnixNetVConnection *vc)
 {
+  int retval = EVENT_CONT;
   vc->recursion++;
   if (vc->read.vio.cont) {
-vc->read.vio.cont->handleEvent(event, &vc->read.vio);
+retval = vc->read.vio.cont->dispatchEvent(event, &vc->read.vio);
   } else {
 switch (event) {
 case VC_EVENT_EOS:
@@ -102,16 +103,17 @@ read_signal_and_update(int event, UnixNetVConnection *vc)
 vc->nh->free_netvc(vc);
 return EVENT_DONE;
   } else {
-return EVENT_CONT;
+return retval;
   }
 }
 
 static inline int
 write_signal_and_update(int event, UnixNetVConnection *vc)
 {
+  int retval = EVENT_CONT;
   vc->recursion++;
   if (vc->write.vio.cont) {
-vc->write.vio.cont->handleEvent(event, &vc->write.vio);
+retval = vc->write.vio.cont->dispatchEvent(event, &vc->write.vio);
   } else {
 switch (event) {
 case VC_EVENT_EOS:
@@ -133,7 +135,7 @@ write_signal_and_update(int event, UnixNetVConnection *vc)
 vc->nh->free_netvc(vc);
 return EVENT_DONE;
   } else {
-return EVENT_CONT;
+return retval;
   }
 }
 



[trafficserver] branch master updated: Deal with the case when the hostdb cont may not have a mutex

2018-08-13 Thread shinrich
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 80bd615  Deal with the case when the hostdb cont may not have a mutex
80bd615 is described below

commit 80bd6150dcba6b676ecb6e66de775602927dafad
Author: Susan Hinrichs 
AuthorDate: Mon Aug 13 16:05:53 2018 +

Deal with the case when the hostdb cont may not have a mutex
---
 iocore/hostdb/HostDB.cc | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index b82b69e..f62cf24 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -1490,20 +1490,32 @@ HostDBContinuation::dnsEvent(int event, HostEnt *e)
 return EVENT_CONT;
   }
 
-  MUTEX_TRY_LOCK_FOR(lock, action.mutex, thread, action.continuation);
   // We have seen cases were the action.mutex != action.continuation.mutex.
   // Since reply_to_cont will call the hanlder on the action.continuation, 
it is important that we hold
   // that mutex.
-  MUTEX_TRY_LOCK_FOR(lock2, action.continuation->mutex, thread, 
action.continuation);
-  if (!lock.is_locked() || !lock2.is_locked()) {
+  bool need_to_reschedule = true;
+  MUTEX_TRY_LOCK_FOR(lock, action.mutex, thread, action.continuation);
+  if (lock.is_locked()) {
+need_to_reschedule = !action.cancelled;
+if (!action.cancelled) {
+  if (action.continuation->mutex) {
+MUTEX_TRY_LOCK_FOR(lock2, action.continuation->mutex, thread, 
action.continuation);
+if (lock2.is_locked()) {
+  reply_to_cont(action.continuation, r, is_srv());
+  need_to_reschedule = false;
+}
+  } else {
+reply_to_cont(action.continuation, r, is_srv());
+need_to_reschedule = false;
+  }
+}
+  }
+  if (need_to_reschedule) {
 remove_trigger_pending_dns();
 SET_HANDLER((HostDBContHandler)&HostDBContinuation::probeEvent);
 thread->schedule_in(this, HOST_DB_RETRY_PERIOD);
 return EVENT_CONT;
   }
-  if (!action.cancelled) {
-reply_to_cont(action.continuation, r, is_srv());
-  }
 }
 // wake up everyone else who is waiting
 remove_trigger_pending_dns();



[trafficserver] branch master updated: Optimize: Assign nh->mutex to new NetVC first and switch to new mutex within UnixNetVC::acceptEvent

2018-08-13 Thread oknet
This is an automated email from the ASF dual-hosted git repository.

oknet 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 9e32c19  Optimize: Assign nh->mutex to new NetVC first and switch to 
new mutex within UnixNetVC::acceptEvent
9e32c19 is described below

commit 9e32c19872870705df255f7dfea46f6eaec226a9
Author: Oknet Xu 
AuthorDate: Fri Aug 10 15:09:09 2018 +0800

Optimize: Assign nh->mutex to new NetVC first and switch to new mutex 
within UnixNetVC::acceptEvent
---
 iocore/net/UnixNetAccept.cc  | 58 +++-
 iocore/net/UnixNetVConnection.cc | 15 +++
 2 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc
index f4ee913..21f39c4 100644
--- a/iocore/net/UnixNetAccept.cc
+++ b/iocore/net/UnixNetAccept.cc
@@ -113,7 +113,6 @@ net_accept(NetAccept *na, void *ep, bool blockable)
 vc->id = net_next_connection_number();
 vc->con.move(con);
 vc->submit_time = Thread::get_hrtime();
-vc->mutex   = new_ProxyMutex();
 vc->action_ = *na->action_;
 vc->set_is_transparent(na->opt.f_inbound_transparent);
 vc->set_context(NET_VCONNECTION_IN);
@@ -125,10 +124,25 @@ net_accept(NetAccept *na, void *ep, bool blockable)
 #endif
 SET_CONTINUATION_HANDLER(vc, 
(NetVConnHandler)&UnixNetVConnection::acceptEvent);
 
+EThread *t;
+NetHandler *h;
 if (e->ethread->is_event_type(na->opt.etype)) {
-  vc->dispatchEvent(EVENT_NONE, e);
+  t = e->ethread;
+  h = get_NetHandler(t);
+  // Assign NetHandler->mutex to NetVC
+  vc->mutex = h->mutex;
+  MUTEX_TRY_LOCK(lock, h->mutex, t);
+  if (!lock.is_locked()) {
+t->schedule_in(vc, HRTIME_MSECONDS(net_retry_delay));
+  } else {
+vc->handleEvent(EVENT_NONE, e);
+  }
 } else {
-  eventProcessor.schedule_imm(vc, na->opt.etype);
+  t = eventProcessor.assign_thread(na->opt.etype);
+  h = get_NetHandler(t);
+  // Assign NetHandler->mutex to NetVC
+  vc->mutex = h->mutex;
+  t->schedule_imm(vc);
 }
   } while (loop);
 
@@ -282,12 +296,11 @@ NetAccept::do_blocking_accept(EThread *t)
   int loop   = accept_till_done;
   UnixNetVConnection *vc = nullptr;
   Connection con;
+  con.sock_type = SOCK_STREAM;
 
   // do-while for accepting all the connections
   // added by YTS Team, yamsat
   do {
-ink_hrtime now = Thread::get_hrtime();
-
 // Throttle accepts
 while (!opt.backdoor && check_net_throttle(ACCEPT)) {
   check_throttle_warning(ACCEPT);
@@ -296,7 +309,6 @@ NetAccept::do_blocking_accept(EThread *t)
 goto Lerror;
   }
   NET_SUM_DYN_STAT(net_connections_throttled_in_stat, num_throttled);
-  now = Thread::get_hrtime();
 }
 
 if ((res = server.accept(&con)) < 0) {
@@ -321,6 +333,8 @@ NetAccept::do_blocking_accept(EThread *t)
   return -1;
 }
 
+NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1);
+
 // Use 'nullptr' to Bypass thread allocator
 vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(nullptr);
 if (unlikely(!vc)) {
@@ -328,11 +342,9 @@ NetAccept::do_blocking_accept(EThread *t)
 }
 
 NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1);
-NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1);
 vc->id = net_next_connection_number();
 vc->con.move(con);
-vc->submit_time = now;
-vc->mutex   = new_ProxyMutex();
+vc->submit_time = Thread::get_hrtime();
 vc->action_ = *action_;
 vc->set_is_transparent(opt.f_inbound_transparent);
 vc->options.packet_mark = opt.packet_mark;
@@ -348,8 +360,12 @@ NetAccept::do_blocking_accept(EThread *t)
 }
 #endif
 SET_CONTINUATION_HANDLER(vc, 
(NetVConnHandler)&UnixNetVConnection::acceptEvent);
-// eventProcessor.schedule_imm(vc, getEtype());
-eventProcessor.schedule_imm_signal(vc, opt.etype);
+
+EThread *t= eventProcessor.assign_thread(opt.etype);
+NetHandler *h = get_NetHandler(t);
+// Assign NetHandler->mutex to NetVC
+vc->mutex = h->mutex;
+t->schedule_imm_signal(vc);
   } while (loop);
 
   return 1;
@@ -406,6 +422,7 @@ NetAccept::acceptFastEvent(int event, void *ep)
   (void)e;
   int bufsz, res = 0;
   Connection con;
+  con.sock_type = SOCK_STREAM;
 
   UnixNetVConnection *vc = nullptr;
   int loop   = accept_till_done;
@@ -445,16 +462,6 @@ NetAccept::acceptFastEvent(int event, void *ep)
   }
 }
   }
-
-  if (opt.sockopt_flags & NetVCOptions::SOCK_OPT_NO_DELAY) {
-safe_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, SOCKOPT_ON, sizeof(int));
-Debug("socket", "::acceptFastEvent: setsockopt() TCP_NODELAY on 
socket");
-  }
-
-  if (opt.sockopt_flags & NetVCOptions::SOCK_OPT_KEEP_ALIVE) {
-safe_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, SO

[trafficserver] branch quic-latest updated: Check state of handshake before change encryption level

2018-08-13 Thread masaori
This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/quic-latest by this push:
 new a9a6890  Check state of handshake before change encryption level
a9a6890 is described below

commit a9a689061d75b1024bba6eff25170aa1705b8a0e
Author: Masaori Koshiba 
AuthorDate: Tue Aug 14 14:47:09 2018 +0900

Check state of handshake before change encryption level

To avoid sending CONNECTION_CLOSE (TRANSPORT_PARAMETER_ERROR) on 1-RTT 
packet when
handshake is aborted by TP validation.
---
 iocore/net/quic/QUICHandshake.cc| 2 ++
 iocore/net/quic/QUICHandshakeProtocol.h | 1 +
 iocore/net/quic/QUICTLS.cc  | 8 
 iocore/net/quic/QUICTLS.h   | 8 
 iocore/net/quic/QUICTLS_openssl.cc  | 6 +-
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/iocore/net/quic/QUICHandshake.cc b/iocore/net/quic/QUICHandshake.cc
index f6ea128..637b8cc 100644
--- a/iocore/net/quic/QUICHandshake.cc
+++ b/iocore/net/quic/QUICHandshake.cc
@@ -471,5 +471,7 @@ QUICHandshake::_abort_handshake(QUICTransErrorCode code)
 {
   QUICHSDebug("Abort Handshake");
 
+  this->_hs_protocol->abort_handshake();
+
   this->_qc->close(QUICConnectionErrorUPtr(new QUICConnectionError(code)));
 }
diff --git a/iocore/net/quic/QUICHandshakeProtocol.h 
b/iocore/net/quic/QUICHandshakeProtocol.h
index 9556155..88dc369 100644
--- a/iocore/net/quic/QUICHandshakeProtocol.h
+++ b/iocore/net/quic/QUICHandshakeProtocol.h
@@ -85,4 +85,5 @@ public:
   virtual bool decrypt_pn(uint8_t *unprotected_pn, uint8_t 
&unprotected_pn_len, const uint8_t *protected_pn,
   uint8_t protected_pn_len, const uint8_t *sample, 
QUICKeyPhase phase) const   = 0;
   virtual QUICEncryptionLevel current_encryption_level() const 
= 0;
+  virtual void abort_handshake()   
= 0;
 };
diff --git a/iocore/net/quic/QUICTLS.cc b/iocore/net/quic/QUICTLS.cc
index 862c25d..fb8803e 100644
--- a/iocore/net/quic/QUICTLS.cc
+++ b/iocore/net/quic/QUICTLS.cc
@@ -129,6 +129,14 @@ QUICTLS::current_encryption_level() const
 }
 
 void
+QUICTLS::abort_handshake()
+{
+  this->_state = HandshakeState::ABORTED;
+
+  return;
+}
+
+void
 QUICTLS::_update_encryption_level(QUICEncryptionLevel level)
 {
   if (this->_current_level < level) {
diff --git a/iocore/net/quic/QUICTLS.h b/iocore/net/quic/QUICTLS.h
index c070cbb..81fd96d 100644
--- a/iocore/net/quic/QUICTLS.h
+++ b/iocore/net/quic/QUICTLS.h
@@ -43,6 +43,12 @@ public:
   QUICTLS(SSL *ssl, NetVConnectionContext_t nvc_ctx, bool stateless);
   ~QUICTLS();
 
+  // TODO: integrate with _early_data_processed
+  enum class HandshakeState {
+PROCESSING,
+ABORTED,
+  };
+
   static QUICEncryptionLevel get_encryption_level(int msg_type);
 
   int handshake(QUICHandshakeMsgs *out, const QUICHandshakeMsgs *in) override;
@@ -61,6 +67,7 @@ public:
   bool decrypt_pn(uint8_t *unprotected_pn, uint8_t &unprotected_pn_len, const 
uint8_t *protected_pn, uint8_t protected_pn_len,
   const uint8_t *sample, QUICKeyPhase phase) const override;
   QUICEncryptionLevel current_encryption_level() const override;
+  void abort_handshake() override;
 
   // FIXME SSL handle should not be exported
   SSL *ssl_handle();
@@ -95,4 +102,5 @@ private:
   bool _early_data_processed = false;
   bool _early_data   = true;
   QUICEncryptionLevel _current_level = QUICEncryptionLevel::INITIAL;
+  HandshakeState _state  = HandshakeState::PROCESSING;
 };
diff --git a/iocore/net/quic/QUICTLS_openssl.cc 
b/iocore/net/quic/QUICTLS_openssl.cc
index 7cb1a7a..9c1be67 100644
--- a/iocore/net/quic/QUICTLS_openssl.cc
+++ b/iocore/net/quic/QUICTLS_openssl.cc
@@ -183,6 +183,10 @@ key_cb(SSL *ssl, int name, const unsigned char *secret, 
size_t secret_len, const
 void
 QUICTLS::update_key_materials_on_key_cb(std::unique_ptr km, int 
name)
 {
+  if (this->_state == HandshakeState::ABORTED) {
+return;
+  }
+
   switch (name) {
   case SSL_KEY_CLIENT_EARLY_TRAFFIC:
 // this->_update_encryption_level(QUICEncryptionLevel::ZERO_RTT);
@@ -251,7 +255,7 @@ int
 QUICTLS::handshake(QUICHandshakeMsgs *out, const QUICHandshakeMsgs *in)
 {
   ink_assert(this->_ssl != nullptr);
-  if (SSL_is_init_finished(this->_ssl)) {
+  if (SSL_is_init_finished(this->_ssl) || this->_state == 
HandshakeState::ABORTED) {
 return 0;
   }