[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. [TS-4160] move the reset of handles to NULL to the operator() from TS-4135. [TS-4160] remove unnecessary reset. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/3e78810b Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/3e78810b Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/3e78810b Branch: refs/heads/ts-4160 Commit: 3e78810b09e44f0ca814b735c543bcb9fde0ec76 Parents: af72c71 Author: Sudheer Vinukonda <[email protected]> Authored: Fri Jan 29 01:00:10 2016 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Mon Feb 1 17:33:27 2016 +0000 ---------------------------------------------------------------------- lib/atscppapi/src/utils_internal.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/3e78810b/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);
