Repository: trafficserver Updated Branches: refs/heads/master 109d7bc62 -> c6ef7b496
TS-3668 Make cache promotion explicit for internal requests, we can make it optional later if someone really, really feel that internal requests should not get promoted like this Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/e90d9b91 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/e90d9b91 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/e90d9b91 Branch: refs/heads/master Commit: e90d9b918c3cb1ece639109a15031fd6d898f340 Parents: 109d7bc Author: Leif Hedstrom <[email protected]> Authored: Thu Jun 4 19:12:06 2015 -0600 Committer: Leif Hedstrom <[email protected]> Committed: Mon Jun 8 16:25:14 2015 -0600 ---------------------------------------------------------------------- .../experimental/cache_promote/cache_promote.cc | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/e90d9b91/plugins/experimental/cache_promote/cache_promote.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/cache_promote/cache_promote.cc b/plugins/experimental/cache_promote/cache_promote.cc index bb49bcd..a7be269 100644 --- a/plugins/experimental/cache_promote/cache_promote.cc +++ b/plugins/experimental/cache_promote/cache_promote.cc @@ -383,27 +383,32 @@ cont_handle_policy(TSCont contp, TSEvent event, void *edata) { TSHttpTxn txnp = static_cast<TSHttpTxn>(edata); PromotionConfig *config = static_cast<PromotionConfig *>(TSContDataGet(contp)); - int obj_status; switch (event) { // Main HOOK case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE: - if (TS_ERROR != TSHttpTxnCacheLookupStatusGet(txnp, &obj_status)) { - switch (obj_status) { - case TS_CACHE_LOOKUP_MISS: - case TS_CACHE_LOOKUP_SKIPPED: - if (config->getPolicy()->doSample() && config->getPolicy()->doPromote(txnp)) { - TSDebug(PLUGIN_NAME, "cache-status is %d, and leaving cache on (promoted)", obj_status); - } else { - TSDebug(PLUGIN_NAME, "cache-status is %d, and turning off the cache (not promoted)", obj_status); - TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, contp); + if (TS_SUCCESS != TSHttpTxnIsInternal(txnp)) { + int obj_status; + + if (TS_ERROR != TSHttpTxnCacheLookupStatusGet(txnp, &obj_status)) { + switch (obj_status) { + case TS_CACHE_LOOKUP_MISS: + case TS_CACHE_LOOKUP_SKIPPED: + if (config->getPolicy()->doSample() && config->getPolicy()->doPromote(txnp)) { + TSDebug(PLUGIN_NAME, "cache-status is %d, and leaving cache on (promoted)", obj_status); + } else { + TSDebug(PLUGIN_NAME, "cache-status is %d, and turning off the cache (not promoted)", obj_status); + TSHttpTxnHookAdd(txnp, TS_HTTP_READ_RESPONSE_HDR_HOOK, contp); + } + break; + default: + // Do nothing, just let it handle the lookup. + TSDebug(PLUGIN_NAME, "cache-status is %d (hit), nothing to do", obj_status); + break; } - break; - default: - // Do nothing, just let it handle the lookup. - TSDebug(PLUGIN_NAME, "cache-status is %d (hit), nothing to do", obj_status); - break; } + } else { + TSDebug(PLUGIN_NAME, "Request is an internal (plugin) request, implicitly promoted"); } break;
