[trafficserver] branch quic-latest updated (5b5efec -> 7a9d7fd)

2019-08-15 Thread maskit
This is an automated email from the ASF dual-hosted git repository.

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


from 5b5efec  Print sending Retry packets
 add 7a9d7fd  fix typo

No new revisions were added by this update.

Summary of changes:
 proxy/http3/QPACK.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



[trafficserver] branch master updated: Fix QUIC build

2019-08-15 Thread maskit
This is an automated email from the ASF dual-hosted git repository.

maskit 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 e05cae1  Fix QUIC build
e05cae1 is described below

commit e05cae1ad680f0f2b04e9d12e1d94afa612a03c3
Author: Masakazu Kitajo 
AuthorDate: Fri Aug 16 09:55:38 2019 +0900

Fix QUIC build

PR #5077 broke QUIC build
---
 src/traffic_quic/traffic_quic.cc | 38 ++
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/traffic_quic/traffic_quic.cc b/src/traffic_quic/traffic_quic.cc
index a03c29a..1c290eb 100644
--- a/src/traffic_quic/traffic_quic.cc
+++ b/src/traffic_quic/traffic_quic.cc
@@ -182,13 +182,6 @@ Log::trace_out(sockaddr const *, unsigned short, char 
const *, ...)
 
 #include "InkAPIInternal.h"
 
-int
-APIHook::invoke(int, void *)
-{
-  ink_assert(false);
-  return 0;
-}
-
 APIHook *
 APIHook::next() const
 {
@@ -196,13 +189,6 @@ APIHook::next() const
   return nullptr;
 }
 
-APIHook *
-APIHooks::get() const
-{
-  ink_assert(false);
-  return nullptr;
-}
-
 void
 APIHooks::clear()
 {
@@ -215,10 +201,30 @@ APIHooks::append(INKContInternal *)
   ink_abort("do not call stub");
 }
 
+int
+APIHook::invoke(int, void *) const
+{
+  ink_assert(false);
+  return 0;
+}
+
+APIHook *
+APIHooks::head() const
+{
+  return nullptr;
+}
+
+HttpHookState::HttpHookState() {}
+
 void
-APIHooks::prepend(INKContInternal *)
+HttpHookState::init(TSHttpHookID id, HttpAPIHooks const *global, HttpAPIHooks 
const *ssn, HttpAPIHooks const *txn)
 {
-  ink_abort("do not call stub");
+}
+
+APIHook const *
+HttpHookState::getNext()
+{
+  return nullptr;
 }
 
 void



[trafficserver] branch master updated: Cleanup: Signal READ_READY event only if the buffer is readable

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

masaori 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 03ff337  Cleanup: Signal READ_READY event only if the buffer is 
readable
03ff337 is described below

commit 03ff3379fbaffb433e632e7d302856699ffeb3a6
Author: Masaori Koshiba 
AuthorDate: Wed Aug 14 10:33:59 2019 +0900

Cleanup: Signal READ_READY event only if the buffer is readable

READ_READY event is always signaled itself when Http2ClientSession is 
started.
But this could waste some CPU cycle if there no data to read.
---
 proxy/http2/Http2ClientSession.cc | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/proxy/http2/Http2ClientSession.cc 
b/proxy/http2/Http2ClientSession.cc
index c55cc5c..cc20c57 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -165,19 +165,20 @@ Http2ClientSession::free()
 void
 Http2ClientSession::start()
 {
-  VIO *read_vio;
-
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
 
   SET_HANDLER(&Http2ClientSession::main_event_handler);
   
HTTP2_SET_SESSION_HANDLER(&Http2ClientSession::state_read_connection_preface);
 
-  read_vio  = this->do_io_read(this, INT64_MAX, this->read_buffer);
-  write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);
+  VIO *read_vio = this->do_io_read(this, INT64_MAX, this->read_buffer);
+  write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);
 
   this->connection_state.init();
   send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_INIT, 
this);
-  this->handleEvent(VC_EVENT_READ_READY, read_vio);
+
+  if (this->sm_reader->is_read_avail_more_than(0)) {
+this->handleEvent(VC_EVENT_READ_READY, read_vio);
+  }
 }
 
 void



[trafficserver] branch master updated: Cleanup: Remove unused function & old comments

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

masaori 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 59c4a58  Cleanup: Remove unused function & old comments
59c4a58 is described below

commit 59c4a58adca8cdbb3dd540ec8f8db0238d9b919c
Author: Masaori Koshiba 
AuthorDate: Wed Aug 14 10:06:40 2019 +0900

Cleanup: Remove unused function & old comments
---
 proxy/http2/Http2ClientSession.cc | 6 --
 proxy/http2/Http2ClientSession.h  | 6 --
 2 files changed, 12 deletions(-)

diff --git a/proxy/http2/Http2ClientSession.cc 
b/proxy/http2/Http2ClientSession.cc
index 425582a..c55cc5c 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -175,12 +175,6 @@ Http2ClientSession::start()
   read_vio  = this->do_io_read(this, INT64_MAX, this->read_buffer);
   write_vio = this->do_io_write(this, INT64_MAX, this->sm_writer);
 
-  // 3.5 HTTP/2 Connection Preface. Upon establishment of a TCP connection and
-  // determination that HTTP/2 will be used by both peers, each endpoint MUST
-  // send a connection preface as a final confirmation ...
-  // this->write_buffer->write(HTTP2_CONNECTION_PREFACE,
-  // HTTP2_CONNECTION_PREFACE_LEN);
-
   this->connection_state.init();
   send_connection_event(&this->connection_state, HTTP2_SESSION_EVENT_INIT, 
this);
   this->handleEvent(VC_EVENT_READ_READY, read_vio);
diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h
index b7b4ce5..433be89 100644
--- a/proxy/http2/Http2ClientSession.h
+++ b/proxy/http2/Http2ClientSession.h
@@ -303,12 +303,6 @@ public:
 }
   }
 
-  int64_t
-  write_buffer_size()
-  {
-return write_buffer->max_read_avail();
-  }
-
   // Record history from Http2ConnectionState
   void remember(const SourceLocation &location, int event, int reentrant = 
NO_REENTRANT);
 



[trafficserver] branch master updated (296cf29 -> dc06916)

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

masaori pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from 296cf29  Record HttpSM Id on new transaction
 add dc06916  Make client_context_dump test resilient to dump order changes

No new revisions were added by this update.

Summary of changes:
 .../pluginTest/client_context_dump/client_context_dump.test.py  | 6 --
 .../pluginTest/client_context_dump/gold/client_context_dump.gold| 2 --
 2 files changed, 4 insertions(+), 4 deletions(-)
 delete mode 100644 
tests/gold_tests/pluginTest/client_context_dump/gold/client_context_dump.gold



[trafficserver] branch master updated: Record HttpSM Id on new transaction

2019-08-15 Thread vmamidi
This is an automated email from the ASF dual-hosted git repository.

vmamidi 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 296cf29  Record HttpSM Id on new transaction
296cf29 is described below

commit 296cf29b02bf3aba6d22a4a7e66ae5441f5a212c
Author: Masaori Koshiba 
AuthorDate: Thu Aug 15 14:46:29 2019 +0900

Record HttpSM Id on new transaction

There is a path of Http2Stream::update_read_request() starts shutdown
and make current_reader nullptr. Copying HttpSM Id from current_reader
should be done before the update_read_request() call.
---
 proxy/http2/Http2Stream.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
index 9132f62..da681d3 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -148,6 +148,9 @@ Http2Stream::decode_header_blocks(HpackHandle 
&hpack_handle, uint32_t maximum_ta
 void
 Http2Stream::send_request(Http2ConnectionState &cstate)
 {
+  ink_release_assert(this->current_reader != nullptr);
+  this->_http_sm_id = this->current_reader->sm_id;
+
   // Convert header to HTTP/1.1 format
   http2_convert_header_from_2_to_1_1(&_req_header);
 
@@ -174,7 +177,6 @@ Http2Stream::send_request(Http2ConnectionState &cstate)
 
   // Is there a read_vio request waiting?
   this->update_read_request(INT64_MAX, true);
-  this->_http_sm_id = this->current_reader->sm_id;
 }
 
 bool



[trafficserver] branch master updated: make check race condition fix

2019-08-15 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 f0cbc11  make check race condition fix
f0cbc11 is described below

commit f0cbc11e5286ffc18e565c2516da77b37e504d9b
Author: Gancho Tenev 
AuthorDate: Mon Aug 12 17:28:11 2019 -0700

make check race condition fix

Avoid race conditions when creating unique temporary
unit-test sandbox directory by using mkdtemp().
---
 proxy/http/remap/unit-tests/plugin_testing_common.cc | 13 +
 proxy/http/remap/unit-tests/plugin_testing_common.h  |  3 +++
 proxy/http/remap/unit-tests/test_PluginDso.cc|  9 +
 proxy/http/remap/unit-tests/test_PluginFactory.cc| 13 +
 proxy/http/remap/unit-tests/test_RemapPlugin.cc  | 20 +++-
 5 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/proxy/http/remap/unit-tests/plugin_testing_common.cc 
b/proxy/http/remap/unit-tests/plugin_testing_common.cc
index d5d08d3..a54422c 100644
--- a/proxy/http/remap/unit-tests/plugin_testing_common.cc
+++ b/proxy/http/remap/unit-tests/plugin_testing_common.cc
@@ -37,3 +37,16 @@ PrintToStdErr(const char *fmt, ...)
   vfprintf(stderr, fmt, args);
   va_end(args);
 }
+
+fs::path
+getTemporaryDir()
+{
+  std::error_code ec;
+  fs::path tmpDir = fs::canonical(fs::temp_directory_path(), ec);
+  tmpDir /= "sandbox_XX";
+
+  char dirNameTemplate[tmpDir.string().length() + 1];
+  sprintf(dirNameTemplate, "%s", tmpDir.c_str());
+
+  return fs::path(mkdtemp(dirNameTemplate));
+}
diff --git a/proxy/http/remap/unit-tests/plugin_testing_common.h 
b/proxy/http/remap/unit-tests/plugin_testing_common.h
index 12346ea..66a8dd6 100644
--- a/proxy/http/remap/unit-tests/plugin_testing_common.h
+++ b/proxy/http/remap/unit-tests/plugin_testing_common.h
@@ -40,6 +40,9 @@
 
 extern thread_local PluginThreadContext *pluginThreadContext;
 
+/* A temp sandbox to play with our toys used for all fun with this test-bench 
*/
+fs::path getTemporaryDir();
+
 class PluginDebugObject
 {
 public:
diff --git a/proxy/http/remap/unit-tests/test_PluginDso.cc 
b/proxy/http/remap/unit-tests/test_PluginDso.cc
index c31e1d6..092261b 100644
--- a/proxy/http/remap/unit-tests/test_PluginDso.cc
+++ b/proxy/http/remap/unit-tests/test_PluginDso.cc
@@ -39,11 +39,8 @@ thread_local PluginThreadContext *pluginThreadContext;
 
 std::error_code ec;
 
-/* A temp sandbox to play with our toys used for all fun with this test-bench 
*/
-static fs::path tmpDir = fs::canonical(fs::temp_directory_path(), ec);
-
 /* The following are dirs that are used commonly in the unit-tests */
-static fs::path sandboxDir = tmpDir / fs::path("sandbox");
+static fs::path sandboxDir = getTemporaryDir();
 static fs::path runtimeDir = sandboxDir / fs::path("runtime");
 static fs::path searchDir  = sandboxDir / fs::path("search");
 static fs::path pluginBuildDir = fs::current_path() / 
fs::path("unit-tests/.libs");
@@ -91,6 +88,8 @@ public:
  */
 SCENARIO("loading plugins", "[plugin][core]")
 {
+  REQUIRE_FALSE(sandboxDir.empty());
+
   clean();
   std::string error;
 
@@ -322,6 +321,8 @@ SCENARIO("loading plugins", "[plugin][core]")
  */
 SCENARIO("looking for symbols inside a plugin DSO", "[plugin][core]")
 {
+  REQUIRE_FALSE(sandboxDir.empty());
+
   clean();
   std::string error;
 
diff --git a/proxy/http/remap/unit-tests/test_PluginFactory.cc 
b/proxy/http/remap/unit-tests/test_PluginFactory.cc
index c75040e..9c2d819 100644
--- a/proxy/http/remap/unit-tests/test_PluginFactory.cc
+++ b/proxy/http/remap/unit-tests/test_PluginFactory.cc
@@ -77,11 +77,8 @@ getDebugObject(const PluginDso &plugin)
   }
 }
 
-/* A temp sandbox to play with our toys used for all fun with this test-bench 
*/
-static fs::path tmpDir = fs::canonical(fs::temp_directory_path(), ec);
-
 /* The following are paths that are used commonly in the unit-tests */
-static fs::path sandboxDir = tmpDir / "sandbox";
+static fs::path sandboxDir = getTemporaryDir();
 static fs::path runtimeRootDir = sandboxDir / "runtime";
 static fs::path runtimeDir = runtimeRootDir / tempComponent;
 static fs::path searchDir  = sandboxDir / "search";
@@ -149,6 +146,8 @@ validateSuccessfulConfigPathTest(const RemapPluginInst 
*pluginInst, const std::s
 
 SCENARIO("loading plugins", "[plugin][core]")
 {
+  REQUIRE_FALSE(sandboxDir.empty());
+
   fs::path effectivePath;
   fs::path runtimePath;
   std::string error;
@@ -249,6 +248,8 @@ SCENARIO("loading plugins", "[plugin][core]")
 
 SCENARIO("multiple search dirs + multiple or no plugins installed", 
"[plugin][core]")
 {
+  REQUIRE_FALSE(sandboxDir.empty());
+
   GIVEN("multiple search dirs specified for the plugin search")
   {
 /* Create the directory structure and install plugins */
@@ -386,6 +387,8 @@ getPluginVersion(const PluginDso &plugin)
 
 SCENARIO("l

[trafficserver] branch master updated: Doc: Improve handling of build when documentation is not enabled.

2019-08-15 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc 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 921bed6  Doc: Improve handling of build when documentation is not 
enabled.
921bed6 is described below

commit 921bed6deeec79b58b7e5228dc71a1ed735337b1
Author: Alan M. Carroll 
AuthorDate: Thu Aug 8 13:31:35 2019 -0500

Doc: Improve handling of build when documentation is not enabled.
---
 doc/Makefile.am | 85 +
 1 file changed, 56 insertions(+), 29 deletions(-)

diff --git a/doc/Makefile.am b/doc/Makefile.am
index f6c174f..46dded4 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -16,6 +16,14 @@
 
 .PHONY: help dirhtml singlehtml epub latex man changes linkcheck doxygen
 
+# You can set these variables from the command line.
+PAPER = letter
+BUILDDIR  = docbuild
+
+if BUILD_DOCS
+
+SUBDIRS = uml
+
 if BUILD_MANPAGES
 
 man1_MANS = $(TS_MAN1_MANPAGES)
@@ -28,25 +36,9 @@ $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS): man
 # Hook the 'all' target so that the man pages get generated in the "all" 
target, prior
 # to "make install". If we leave it to "make install" time, then the man pages 
are likely
 # to me generated as root.
-if BUILD_DOCS
-SUBDIRS = uml
 all-am: $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS)
-endif
-
-endif
-
-clean-local:
-   -rm -rf $(BUILDDIR)/* _build/html/* xml
-
-doxygen: Doxyfile
-   $(DOXYGEN)
-
-# Makefile for Sphinx documentation
-#
 
-# You can set these variables from the command line.
-PAPER = letter
-BUILDDIR  = docbuild
+endif # BUILD_MANPAGES
 
 # [amc] LaTex apparently doesn't work as of Sphinx 1.6.1
 # see https://media.readthedocs.org/pdf/sphinx/1.6.3/sphinx.pdf
@@ -64,18 +56,6 @@ SBUILD = PAPEROPT_a4="$(PAPEROPT_a4)" 
PAPEROPT_letter="$(PAPEROPT_letter)" PAPER
-c $(srcdir) \
$(ALLSPHINXOPTS)
 
-help:
-   @echo "Please use \`make ' where  is one of"
-   @echo "  html   to make standalone HTML files"
-   @echo "  dirhtmlto make HTML files named index.html in directories"
-   @echo "  singlehtml to make a single large HTML file"
-   @echo "  epub   to make an epub"
-   @echo "  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
-   @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-   @echo "  manto make manual pages"
-   @echo "  changesto make an overview of all changed/added/deprecated 
items"
-   @echo "  linkcheck  to check all external links for integrity"
-
 html-local:
$(SBUILD) -d $(BUILDDIR)/doctrees -b html $(srcdir) $(BUILDDIR)/html
@echo
@@ -111,3 +91,50 @@ changes:
 
 linkcheck:
@echo FIXME
+
+else # NOT BUILD_DOCS
+
+html-local:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+dirhtml:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+singlehtml:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+epub:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+latex:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+man:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+changes:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+linkcheck:
+   @echo "Documentation not enabled. See configure --enable-docs."
+
+endif # BUILD_DOCS
+
+clean-local:
+   -rm -rf $(BUILDDIR)/* _build/html/* xml
+
+doxygen: Doxyfile
+   $(DOXYGEN)
+
+help:
+   @echo "Please use \`make ' where  is one of"
+   @echo "  html   to make standalone HTML files"
+   @echo "  dirhtmlto make HTML files named index.html in directories"
+   @echo "  singlehtml to make a single large HTML file"
+   @echo "  epub   to make an epub"
+   @echo "  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
+   @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+   @echo "  manto make manual pages"
+   @echo "  changesto make an overview of all changed/added/deprecated 
items"
+   @echo "  linkcheck  to check all external links for integrity"
+



[trafficserver] branch master updated (f316aa6 -> 3418b7e)

2019-08-15 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git.


from f316aa6  compress plugin: document undocumented options
 new a83f118  Limit resources used by regex_remap to prevent crashes on 
resource exhaustion.
 new 3418b7e  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:
 plugins/regex_remap/regex_remap.cc |  16 ++-
 .../regex_remap/gold/regex_remap_crash.gold}   |   7 +-
 .../regex_remap/gold/regex_remap_smoke.gold}   |   7 +-
 .../pluginTest/regex_remap/regex_remap.test.py |  92 
 .../regex_remap/replay/yts-2819.replay.json| 155 +
 5 files changed, 268 insertions(+), 9 deletions(-)
 copy tests/gold_tests/{timeout/timeout.gold => 
pluginTest/regex_remap/gold/regex_remap_crash.gold} (61%)
 copy tests/gold_tests/{timeout/timeout.gold => 
pluginTest/regex_remap/gold/regex_remap_smoke.gold} (57%)
 create mode 100644 tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
 create mode 100644 
tests/gold_tests/pluginTest/regex_remap/replay/yts-2819.replay.json



[trafficserver] 02/02: fix.

2019-08-15 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 3418b7e62858c677579605446bde8d5adb32daf6
Author: Alan M. Carroll 
AuthorDate: Tue Aug 6 16:45:35 2019 -0500

fix.
---
 ...regex_remap_smoke.gold => regex_remap_crash.gold} |  1 +
 .../regex_remap/gold/regex_remap_smoke.gold  |  1 +
 .../pluginTest/regex_remap/regex_remap.test.py   | 20 ++--
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git 
a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold 
b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_crash.gold
similarity index 61%
copy from tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
copy to tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_crash.gold
index 2004217..f57b30c 100644
--- a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
+++ b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_crash.gold
@@ -1,3 +1,4 @@
 HTTP/1.1 200 OK
 ``
+uuid: 180
 ``
diff --git 
a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold 
b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
index 2004217..9d235f5 100644
--- a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
+++ b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
@@ -1,3 +1,4 @@
 HTTP/1.1 200 OK
 ``
+uuid: smoke
 ``
diff --git a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py 
b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
index 016d238..3d001f0 100644
--- a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
+++ b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
@@ -87,22 +87,6 @@ tr = Test.AddTestRun("crash test")
 creq=replay_txns[1]['client-request']
 tr.Processes.Default.Command = curl_and_args + '--header "uuid: {}" 
'.format(creq["headers"]["fields"][1][1]) + '"{}"'.format(creq["url"])
 tr.Processes.Default.ReturnCode = 0
-tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold"
-ts.Disk.diags_log.Content = Testers.ContainsExpression('ERROR: [regex_remap] 
Bad regular expression result -21', "Resource limit exceeded")
-tr.StillRunningAfter = ts
-
-'''
-# 1 Test - Load cache (miss) for later test (path1a)
-tr = Test.AddTestRun("test hit")
-tr.Processes.Default.Command = curl_and_args + ' 
http://127.0.0.1:{}/path1a'.format(ts.Variables.port)
-tr.Processes.Default.ReturnCode = 0
-tr.Processes.Default.Streams.stdout = "gold/regex_reval-miss.gold"
+tr.Processes.Default.Streams.stdout = "gold/regex_remap_crash.gold"
+ts.Disk.diags_log.Content = Testers.ContainsExpression('ERROR: .regex_remap. 
Bad regular expression result -21', "Resource limit exceeded")
 tr.StillRunningAfter = ts
-
-# 2 Test - Load cache (miss) for later test (path2a)
-tr = Test.AddTestRun("test bad URL")
-tr.Processes.Default.Command = curl_and_args + ' 
http://127.0.0.1:{}/path2a'.format(ts.Variables.port)
-tr.Processes.Default.ReturnCode = 0
-tr.Processes.Default.Streams.stdout = "gold/regex_reval-miss.gold"
-tr.StillRunningAfter = ts
-'''



[trafficserver] 01/02: Limit resources used by regex_remap to prevent crashes on resource exhaustion.

2019-08-15 Thread amc
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit a83f118166bf5f68a3e13c8dc51989e8021c7e44
Author: Alan M. Carroll 
AuthorDate: Thu Jul 25 12:35:37 2019 -0500

Limit resources used by regex_remap to prevent crashes on resource 
exhaustion.
---
 plugins/regex_remap/regex_remap.cc |  16 ++-
 .../regex_remap/gold/regex_remap_smoke.gold|   3 +
 .../pluginTest/regex_remap/regex_remap.test.py | 108 ++
 .../regex_remap/replay/yts-2819.replay.json| 155 +
 4 files changed, 279 insertions(+), 3 deletions(-)

diff --git a/plugins/regex_remap/regex_remap.cc 
b/plugins/regex_remap/regex_remap.cc
index 7c71f53..dda5846 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -389,11 +389,14 @@ RemapRegex::compile(const char *&error, int &erroffset)
 return -1;
   }
 
-  _extra = pcre_study(_rex, 0, &error);
-  if ((_extra == nullptr) && (error != nullptr)) {
+  _extra = pcre_study(_rex, PCRE_STUDY_EXTRA_NEEDED, &error);
+  if (error != nullptr) {
 return -1;
   }
 
+  _extra->match_limit_recursion = 2047;
+  _extra->flags |= PCRE_EXTRA_MATCH_LIMIT_RECURSION;
+
   if (pcre_fullinfo(_rex, _extra, PCRE_INFO_CAPTURECOUNT, &ccount) != 0) {
 error = "call to pcre_fullinfo() failed";
 return -1;
@@ -629,6 +632,7 @@ struct RemapInstance {
   bool host  = false;
   int hits   = 0;
   int misses = 0;
+  int failures   = 0;
   std::string filename;
 };
 
@@ -863,6 +867,7 @@ TSRemapDeleteInstance(void *ih)
 fprintf(stderr, "[%s]: Profiling information for regex_remap file 
`%s':\n", now, (ri->filename).c_str());
 fprintf(stderr, "[%s]:Total hits (matches): %d\n", now, ri->hits);
 fprintf(stderr, "[%s]:Total missed (no regex matches): %d\n", now, 
ri->misses);
+fprintf(stderr, "[%s]:Total regex internal errors: %d\n", now, 
ri->failures);
 
 if (ri->hits > 0) { // Avoid divide by zeros...
   int ix = 1;
@@ -970,7 +975,8 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo 
*rri)
   // Apply the regular expressions, in order. First one wins.
   while (re) {
 // Since we check substitutions on parse time, we don't need to reset 
ovector
-if (re->match(match_buf, match_len, ovector) != -1) {
+auto match_result = re->match(match_buf, match_len, ovector);
+if (match_result >= 0) {
   int new_len = re->get_lengths(ovector, lengths, rri, &req_url);
 
   // Set timeouts
@@ -1061,6 +1067,10 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, 
TSRemapRequestInfo *rri)
 }
 break;
   }
+} else if (match_result != -1) {
+  ink_atomic_increment(&(ri->failures), 1);
+  TSError("[%s] Bad regular expression result %d from \"%s\" in file 
\"%s\".", PLUGIN_NAME, match_result, re->regex(),
+  ri->filename.c_str());
 }
 
 // Try the next regex
diff --git 
a/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold 
b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
new file mode 100644
index 000..2004217
--- /dev/null
+++ b/tests/gold_tests/pluginTest/regex_remap/gold/regex_remap_smoke.gold
@@ -0,0 +1,3 @@
+HTTP/1.1 200 OK
+``
+``
diff --git a/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py 
b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
new file mode 100644
index 000..016d238
--- /dev/null
+++ b/tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
@@ -0,0 +1,108 @@
+#  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.
+
+import os
+import time
+import json
+Test.Summary = '''
+Test regex_remap
+'''
+
+## Test description:
+# Load up cache, ensure fresh
+# Create regex reval rule, config reload:
+#  ensure item is staled only once.
+# Add a new rule, config reload:
+#  ensure item isn't restaled again, but rule still in effect.
+#
+# If the rule disappears from regex_revalidate.conf its still loaded!!
+# A rule's expiry can't be changed after the fact!
+
+Test.SkipUnless(
+Condition.PluginExists('regex_remap.so'),
+)
+Test.ContinueOnFail = False
+