Repository: trafficserver
Updated Branches:
  refs/heads/ts-4160 [created] dbe6253c9


[TS-4160] Reset the txn request/response handles at each hook, since core may 
destroy them.


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

Branch: refs/heads/ts-4160
Commit: dbe6253c9f808e04e91d60d84d0aaefb5a52073a
Parents: f8ce9e9
Author: Sudheer Vinukonda <[email protected]>
Authored: Fri Jan 29 01:00:10 2016 +0000
Committer: Sudheer Vinukonda <[email protected]>
Committed: Fri Jan 29 01:00:10 2016 +0000

----------------------------------------------------------------------
 lib/atscppapi/src/Transaction.cc    | 10 ++++++++++
 lib/atscppapi/src/utils_internal.cc | 16 ++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe6253c/lib/atscppapi/src/Transaction.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Transaction.cc b/lib/atscppapi/src/Transaction.cc
index b9396ef..4170fc0 100644
--- a/lib/atscppapi/src/Transaction.cc
+++ b/lib/atscppapi/src/Transaction.cc
@@ -455,6 +455,8 @@ void
 Transaction::initServerRequest()
 {
   static initializeHandles 
initializeServerRequestHandles(TSHttpTxnServerReqGet);
+  state_->server_request_hdr_buf_ = NULL;
+  state_->server_request_hdr_loc_ = NULL;
   if (initializeServerRequestHandles(state_->txn_, 
state_->server_request_hdr_buf_, state_->server_request_hdr_loc_,
                                      "server request")) {
     LOG_DEBUG("Initializing server request");
@@ -466,6 +468,8 @@ void
 Transaction::initServerResponse()
 {
   static initializeHandles 
initializeServerResponseHandles(TSHttpTxnServerRespGet);
+  state_->server_response_hdr_buf_ = NULL;
+  state_->server_response_hdr_loc_ = NULL;
   if (initializeServerResponseHandles(state_->txn_, 
state_->server_response_hdr_buf_, state_->server_response_hdr_loc_,
                                       "server response")) {
     LOG_DEBUG("Initializing server response");
@@ -477,6 +481,8 @@ void
 Transaction::initClientResponse()
 {
   static initializeHandles 
initializeClientResponseHandles(TSHttpTxnClientRespGet);
+  state_->client_response_hdr_buf_ = NULL;
+  state_->client_response_hdr_loc_ = NULL;
   if (initializeClientResponseHandles(state_->txn_, 
state_->client_response_hdr_buf_, state_->client_response_hdr_loc_,
                                       "client response")) {
     LOG_DEBUG("Initializing client response");
@@ -488,6 +494,8 @@ void
 Transaction::initCachedRequest()
 {
   static initializeHandles 
initializeCachedRequestHandles(TSHttpTxnCachedReqGet);
+  state_->cached_request_hdr_buf_ = NULL;
+  state_->cached_request_hdr_loc_ = NULL;
   if (initializeCachedRequestHandles(state_->txn_, 
state_->cached_request_hdr_buf_, state_->cached_request_hdr_loc_,
                                      "cached request")) {
     LOG_DEBUG("Initializing cached request");
@@ -499,6 +507,8 @@ void
 Transaction::initCachedResponse()
 {
   static initializeHandles 
initializeCachedResponseHandles(TSHttpTxnCachedRespGet);
+  state_->cached_response_hdr_buf_ = NULL;
+  state_->cached_response_hdr_loc_ = NULL;
   if (initializeCachedResponseHandles(state_->txn_, 
state_->cached_response_hdr_buf_, state_->cached_response_hdr_loc_,
                                       "cached response")) {
     LOG_DEBUG("Initializing cached response");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/dbe6253c/lib/atscppapi/src/utils_internal.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/utils_internal.cc 
b/lib/atscppapi/src/utils_internal.cc
index ff0012e..5257872 100644
--- a/lib/atscppapi/src/utils_internal.cc
+++ b/lib/atscppapi/src/utils_internal.cc
@@ -52,6 +52,12 @@ handleTransactionEvents(TSCont cont, TSEvent event, void 
*edata)
   LOG_DEBUG("Got event %d on continuation %p for transaction (ats pointer %p, 
object %p)", event, cont, ats_txn_handle,
             &transaction);
 
+  if (event != TS_EVENT_HTTP_POST_REMAP) {
+    // the cached_req and cached_resp handles may be destroyed in the core
+    utils::internal::initTransactionCachedRequest(transaction);
+    utils::internal::initTransactionCachedResponse(transaction);
+  }
+
   switch (event) {
   case TS_EVENT_HTTP_POST_REMAP:
     transaction.getClientRequest().getUrl().reset();
@@ -64,16 +70,18 @@ handleTransactionEvents(TSCont cont, TSEvent event, void 
*edata)
     utils::internal::initTransactionServerRequest(transaction);
     break;
   case TS_EVENT_HTTP_READ_RESPONSE_HDR:
+    // the buffer handles may be destroyed in the core during redirect follow
+    utils::internal::initTransactionServerRequest(transaction);
     utils::internal::initTransactionServerResponse(transaction);
     break;
   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+    // the buffer handles may be destroyed in the core
     utils::internal::initTransactionClientResponse(transaction);
     break;
-  case TS_EVENT_HTTP_READ_CACHE_HDR:
-    utils::internal::initTransactionCachedRequest(transaction);
-    utils::internal::initTransactionCachedResponse(transaction);
-    break;
   case TS_EVENT_HTTP_TXN_CLOSE: { // opening scope to declare plugins variable 
below
+    // the buffer handles may be destroyed in the core during redirect follow
+    utils::internal::initTransactionServerRequest(transaction);
+    utils::internal::initTransactionClientResponse(transaction);
     const std::list<TransactionPlugin *> &plugins = 
utils::internal::getTransactionPlugins(transaction);
     for (std::list<TransactionPlugin *>::const_iterator iter = 
plugins.begin(), end = plugins.end(); iter != end; ++iter) {
       shared_ptr<Mutex> trans_mutex = 
utils::internal::getTransactionPluginMutex(**iter);

Reply via email to