[trafficserver] branch master updated: Fix crash when folloing redirect

2020-04-22 Thread scw00
This is an automated email from the ASF dual-hosted git repository.

scw00 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 36ebb2d  Fix crash when folloing redirect
36ebb2d is described below

commit 36ebb2d2a5cfdf794ea2661ed5f6e55090918d81
Author: YuanYingdong <1975643...@qq.com>
AuthorDate: Wed Mar 25 20:45:10 2020 +0800

Fix crash when folloing redirect

When doing redirect  and get cache read miss, we need to get cache write  
lock first other than directly do cache write directly.
---
 proxy/http/HttpSM.cc   | 7 +++
 proxy/http/HttpTransact.cc | 7 ++-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 9b14343..1bf7500 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7859,10 +7859,9 @@ HttpSM::redirect_request(const char *arg_redirect_url, 
const int arg_redirect_le
   // will do that in handle_api_return under the
   // HttpTransact::SM_ACTION_REDIRECT_READ state
   t_state.parent_result.reset();
-  t_state.request_sent_time   = 0;
-  t_state.response_received_time  = 0;
-  t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;
-  t_state.next_action = HttpTransact::SM_ACTION_REDIRECT_READ;
+  t_state.request_sent_time  = 0;
+  t_state.response_received_time = 0;
+  t_state.next_action= HttpTransact::SM_ACTION_REDIRECT_READ;
   // we have a new OS and need to have DNS lookup the new OS
   t_state.dns_info.lookup_success = false;
   t_state.force_dns   = false;
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index b62fcc2..026870a 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -2106,7 +2106,12 @@ HttpTransact::DecideCacheLookup(State *s)
 if (s->redirect_info.redirect_in_process) {
   // without calling out the CACHE_LOOKUP_COMPLETE_HOOK
   if (s->txn_conf->cache_http) {
-s->cache_info.action = CACHE_DO_WRITE;
+if (s->cache_info.write_lock_state == CACHE_WL_FAIL) {
+  s->cache_info.action   = CACHE_PREPARE_TO_WRITE;
+  s->cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT;
+} else if (s->cache_info.write_lock_state == CACHE_WL_SUCCESS) {
+  s->cache_info.action = CACHE_DO_WRITE;
+}
   }
   LookupSkipOpenServer(s);
 } else {



[trafficserver] branch master updated (24e78f2 -> 016d9c8)

2020-04-22 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 24e78f2  Fixed memory leak in header unit test
 add 016d9c8  Fix deprecated-copy warning in cache tool

No new revisions were added by this update.

Summary of changes:
 src/traffic_cache_tool/CacheTool.cc | 2 ++
 1 file changed, 2 insertions(+)



[trafficserver] branch master updated: Fixed memory leak in header unit test

2020-04-22 Thread bcall
This is an automated email from the ASF dual-hosted git repository.

bcall 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 24e78f2  Fixed memory leak in header unit test
24e78f2 is described below

commit 24e78f275acce36189633aa1c92eb9c60b8fae02
Author: Bryan Call 
AuthorDate: Tue Apr 21 15:35:46 2020 -0700

Fixed memory leak in header unit test
---
 proxy/hdrs/unit_tests/test_HdrUtils.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/proxy/hdrs/unit_tests/test_HdrUtils.cc 
b/proxy/hdrs/unit_tests/test_HdrUtils.cc
index 50cca3a..9c41ae2 100644
--- a/proxy/hdrs/unit_tests/test_HdrUtils.cc
+++ b/proxy/hdrs/unit_tests/test_HdrUtils.cc
@@ -119,6 +119,7 @@ TEST_CASE("HdrUtils", "[proxy][hdrutils]")
   REQUIRE(value == "charlie");
   value = iter.get_next();
   REQUIRE(value.empty());
+  heap->destroy();
 }
 
 TEST_CASE("HdrUtils 2", "[proxy][hdrutils]")
@@ -161,6 +162,7 @@ TEST_CASE("HdrUtils 2", "[proxy][hdrutils]")
   REQUIRE(parse != 0);
   REQUIRE(idx == text.size());
   REQUIRE(0 == memcmp(ts::TextView(buff, idx), text));
+  heap->destroy();
 };
 
 TEST_CASE("HdrUtils 3", "[proxy][hdrutils]")
@@ -203,4 +205,5 @@ TEST_CASE("HdrUtils 3", "[proxy][hdrutils]")
   REQUIRE(parse != 0);
   REQUIRE(idx == text.size());
   REQUIRE(0 == memcmp(ts::TextView(buff, idx), text));
+  heap->destroy();
 };



[trafficserver] branch 9.0.x updated: Normalizes function names to match hook names in intercept plugins

2020-04-22 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new eb2bb6e  Normalizes function names to match hook names in intercept 
plugins
eb2bb6e is described below

commit eb2bb6e44a9cdf97730567ec349dae2ebdb6923d
Author: Randall Meyer 
AuthorDate: Tue Apr 21 12:28:59 2020 -0700

Normalizes function names to match hook names in intercept plugins

(cherry picked from commit 7320d5c5333ea2c346c92a80d276dc68762ad493)
---
 example/plugins/c-api/intercept/intercept.cc | 8 
 plugins/generator/generator.cc   | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/example/plugins/c-api/intercept/intercept.cc 
b/example/plugins/c-api/intercept/intercept.cc
index 4d68be7..03bf86d 100644
--- a/example/plugins/c-api/intercept/intercept.cc
+++ b/example/plugins/c-api/intercept/intercept.cc
@@ -60,7 +60,7 @@
 static TSCont TxnHook;
 static TSCont InterceptHook;
 
-static int InterceptInterceptionHook(TSCont contp, TSEvent event, void *edata);
+static int InterceptInterceptHook(TSCont contp, TSEvent event, void *edata);
 static int InterceptTxnHook(TSCont contp, TSEvent event, void *edata);
 
 // We are going to stream data between Traffic Server and an
@@ -266,7 +266,7 @@ InterceptTransferData(InterceptIO *from, InterceptIO *to)
 // starts with TS_EVENT_NET_ACCEPT, and then continues with
 // TSVConn events.
 static int
-InterceptInterceptionHook(TSCont contp, TSEvent event, void *edata)
+InterceptInterceptHook(TSCont contp, TSEvent event, void *edata)
 {
   argument_type arg(edata);
 
@@ -514,7 +514,7 @@ InterceptTxnHook(TSCont contp, TSEvent event, void *edata)
   switch (event) {
   case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE: {
 if (InterceptShouldInterceptRequest(arg.txn)) {
-  TSCont c = InterceptContCreate(InterceptInterceptionHook, 
TSMutexCreate(), arg.txn);
+  TSCont c = InterceptContCreate(InterceptInterceptHook, TSMutexCreate(), 
arg.txn);
 
   VDEBUG("intercepting origin server request for txn=%p, cont=%p", 
arg.txn, c);
   TSHttpTxnServerIntercept(c, arg.txn);
@@ -548,7 +548,7 @@ TSPluginInit(int /* argc */, const char * /* argv */[])
   // XXX accept hostname and port arguments
 
   TxnHook   = InterceptContCreate(InterceptTxnHook, nullptr, nullptr);
-  InterceptHook = InterceptContCreate(InterceptInterceptionHook, nullptr, 
nullptr);
+  InterceptHook = InterceptContCreate(InterceptInterceptHook, nullptr, 
nullptr);
 
   // Wait until after the cache lookup to decide whether to
   // intercept a request. For cache hits, we will never intercept.
diff --git a/plugins/generator/generator.cc b/plugins/generator/generator.cc
index 743ad51..0401fc7 100644
--- a/plugins/generator/generator.cc
+++ b/plugins/generator/generator.cc
@@ -80,7 +80,7 @@ static uint8_t GeneratorData[32 * 1024];
 static int StatCountBytes = -1;
 static int StatCountResponses = -1;
 
-static int GeneratorInterceptionHook(TSCont contp, TSEvent event, void *edata);
+static int GeneratorInterceptHook(TSCont contp, TSEvent event, void *edata);
 static int GeneratorTxnHook(TSCont contp, TSEvent event, void *edata);
 
 struct GeneratorRequest;
@@ -406,7 +406,7 @@ fail:
 // starts with TS_EVENT_NET_ACCEPT, and then continues with
 // TSVConn events.
 static int
-GeneratorInterceptionHook(TSCont contp, TSEvent event, void *edata)
+GeneratorInterceptHook(TSCont contp, TSEvent event, void *edata)
 {
   argument_type arg(edata);
 
@@ -610,7 +610,7 @@ GeneratorTxnHook(TSCont contp, TSEvent event, void *edata)
 if (status != TS_CACHE_LOOKUP_HIT_FRESH) {
   // This transaction is going to be a cache miss, so intercept it.
   VDEBUG("intercepting origin server request for txn=%p", arg.txn);
-  TSHttpTxnServerIntercept(TSContCreate(GeneratorInterceptionHook, 
TSMutexCreate()), arg.txn);
+  TSHttpTxnServerIntercept(TSContCreate(GeneratorInterceptHook, 
TSMutexCreate()), arg.txn);
 }
 
 break;



[trafficserver] branch 9.0.x updated: Increase the default max_record_entries to match the original compiled in value (#6697)

2020-04-22 Thread zwoop
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new f714deb  Increase the default max_record_entries to match the original 
compiled in value (#6697)
f714deb is described below

commit f714deba9370320bc52ed5234d415afc28e6e9dc
Author: Susan Hinrichs 
AuthorDate: Wed Apr 22 12:52:38 2020 -0500

Increase the default max_record_entries to match the original compiled in 
value (#6697)

Co-authored-by: Susan Hinrichs 
(cherry picked from commit eb232ed3bbcbfa5835825cec20d5bb0ddee87172)
---
 lib/records/P_RecDefs.h | 2 +-
 lib/records/RecCore.cc  | 2 +-
 mgmt/api/CoreAPI.cc | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/records/P_RecDefs.h b/lib/records/P_RecDefs.h
index e987e63..46e4456 100644
--- a/lib/records/P_RecDefs.h
+++ b/lib/records/P_RecDefs.h
@@ -31,7 +31,7 @@
 // additional slots in librecords will be allocated to the plugin metrics. 
These should be
 // updated if we change the internal librecords size significantly.
 #define REC_INTERNAL_RECORDS 1100
-#define REC_MIN_API_RECORDS 500
+#define REC_DEFAULT_API_RECORDS 1400
 
 #define REC_CONFIG_UPDATE_INTERVAL_MS 3000
 #define REC_REMOTE_SYNC_INTERVAL_MS 5000
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 8ab0683..fcb6474 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -34,7 +34,7 @@
 
 // This is needed to manage the size of the librecords record. It can't be 
static, because it needs to be modified
 // and used (read) from several binaries / modules.
-int max_records_entries = REC_INTERNAL_RECORDS + REC_MIN_API_RECORDS;
+int max_records_entries = REC_INTERNAL_RECORDS + REC_DEFAULT_API_RECORDS;
 
 static bool g_initialized = false;
 
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index be5bce4..c9b19e0 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -170,7 +170,8 @@ ProxyStateSet(TSProxyStateT state, TSCacheClearT clear)
 
 // Start with the default options from records.config.
 if (RecGetRecordString_Xmalloc("proxy.config.proxy_binary_opts", 
_options) == REC_ERR_OKAY) {
-  if (max_records_entries == (REC_INTERNAL_RECORDS + REC_MIN_API_RECORDS)) 
{ // Default size, don't need to pass down to _server
+  if (max_records_entries ==
+  (REC_INTERNAL_RECORDS + REC_DEFAULT_API_RECORDS)) { // Default size, 
don't need to pass down to _server
 snprintf(tsArgs, sizeof(tsArgs), "%s", proxy_options);
   } else {
 snprintf(tsArgs, sizeof(tsArgs), "%s --maxRecords %d", proxy_options, 
max_records_entries);



[trafficserver] branch master updated: Increase the default max_record_entries to match the original compiled in value (#6697)

2020-04-22 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 eb232ed  Increase the default max_record_entries to match the original 
compiled in value (#6697)
eb232ed is described below

commit eb232ed3bbcbfa5835825cec20d5bb0ddee87172
Author: Susan Hinrichs 
AuthorDate: Wed Apr 22 12:52:38 2020 -0500

Increase the default max_record_entries to match the original compiled in 
value (#6697)

Co-authored-by: Susan Hinrichs 
---
 lib/records/P_RecDefs.h | 2 +-
 lib/records/RecCore.cc  | 2 +-
 mgmt/api/CoreAPI.cc | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/records/P_RecDefs.h b/lib/records/P_RecDefs.h
index e987e63..46e4456 100644
--- a/lib/records/P_RecDefs.h
+++ b/lib/records/P_RecDefs.h
@@ -31,7 +31,7 @@
 // additional slots in librecords will be allocated to the plugin metrics. 
These should be
 // updated if we change the internal librecords size significantly.
 #define REC_INTERNAL_RECORDS 1100
-#define REC_MIN_API_RECORDS 500
+#define REC_DEFAULT_API_RECORDS 1400
 
 #define REC_CONFIG_UPDATE_INTERVAL_MS 3000
 #define REC_REMOTE_SYNC_INTERVAL_MS 5000
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 8ab0683..fcb6474 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -34,7 +34,7 @@
 
 // This is needed to manage the size of the librecords record. It can't be 
static, because it needs to be modified
 // and used (read) from several binaries / modules.
-int max_records_entries = REC_INTERNAL_RECORDS + REC_MIN_API_RECORDS;
+int max_records_entries = REC_INTERNAL_RECORDS + REC_DEFAULT_API_RECORDS;
 
 static bool g_initialized = false;
 
diff --git a/mgmt/api/CoreAPI.cc b/mgmt/api/CoreAPI.cc
index be5bce4..c9b19e0 100644
--- a/mgmt/api/CoreAPI.cc
+++ b/mgmt/api/CoreAPI.cc
@@ -170,7 +170,8 @@ ProxyStateSet(TSProxyStateT state, TSCacheClearT clear)
 
 // Start with the default options from records.config.
 if (RecGetRecordString_Xmalloc("proxy.config.proxy_binary_opts", 
_options) == REC_ERR_OKAY) {
-  if (max_records_entries == (REC_INTERNAL_RECORDS + REC_MIN_API_RECORDS)) 
{ // Default size, don't need to pass down to _server
+  if (max_records_entries ==
+  (REC_INTERNAL_RECORDS + REC_DEFAULT_API_RECORDS)) { // Default size, 
don't need to pass down to _server
 snprintf(tsArgs, sizeof(tsArgs), "%s", proxy_options);
   } else {
 snprintf(tsArgs, sizeof(tsArgs), "%s --maxRecords %d", proxy_options, 
max_records_entries);