Repository: trafficserver Updated Branches: refs/heads/ts-4160 dbe6253c9 -> 5bfe22907 (forced update)
[TS-4160] Reset the txn request/response handles at each hook, since core may destroy them. [TS-4160] clean up the code and initialize all handles for all hooks. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/5bfe2290 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/5bfe2290 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/5bfe2290 Branch: refs/heads/ts-4160 Commit: 5bfe22907b250c4934ab15da96c9cbca5f27decb 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:43:45 2016 +0000 ---------------------------------------------------------------------- lib/atscppapi/src/Transaction.cc | 10 ++++++++++ lib/atscppapi/src/utils_internal.cc | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/5bfe2290/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/5bfe2290/lib/atscppapi/src/utils_internal.cc ---------------------------------------------------------------------- diff --git a/lib/atscppapi/src/utils_internal.cc b/lib/atscppapi/src/utils_internal.cc index ff0012e..dd7bca4 100644 --- a/lib/atscppapi/src/utils_internal.cc +++ b/lib/atscppapi/src/utils_internal.cc @@ -43,6 +43,18 @@ namespace const int MAX_TXN_ARG = 15; const int TRANSACTION_STORAGE_INDEX = MAX_TXN_ARG; +void +initTransactionHandles(Transaction &transaction) +{ + utils::internal::initTransactionCachedRequest(transaction); + utils::internal::initTransactionCachedResponse(transaction); + utils::internal::initTransactionServerRequest(transaction); + utils::internal::initTransactionServerResponse(transaction); + utils::internal::initTransactionClientResponse(transaction); + + return; +} + int handleTransactionEvents(TSCont cont, TSEvent event, void *edata) { @@ -61,19 +73,14 @@ handleTransactionEvents(TSCont cont, TSEvent event, void *edata) (void)TSHttpTxnClientReqGet(static_cast<TSHttpTxn>(transaction.getAtsHandle()), &hdr_buf, &hdr_loc); break; case TS_EVENT_HTTP_SEND_REQUEST_HDR: - utils::internal::initTransactionServerRequest(transaction); - break; case TS_EVENT_HTTP_READ_RESPONSE_HDR: - utils::internal::initTransactionServerResponse(transaction); - break; case TS_EVENT_HTTP_SEND_RESPONSE_HDR: - utils::internal::initTransactionClientResponse(transaction); - break; case TS_EVENT_HTTP_READ_CACHE_HDR: - utils::internal::initTransactionCachedRequest(transaction); - utils::internal::initTransactionCachedResponse(transaction); + // the buffer handles may be destroyed in the core during redirect follow + initTransactionHandles(transaction); break; case TS_EVENT_HTTP_TXN_CLOSE: { // opening scope to declare plugins variable below + initTransactionHandles(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);
