You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by rr...@apache.org on 2021/04/23 20:52:00 UTC

[trafficserver] branch master updated: if transaction status non-success, bypass intercept plugin (#7724)

This is an automated email from the ASF dual-hosted git repository.

rrm 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 7e3d7fa  if transaction status non-success, bypass intercept plugin (#7724)
7e3d7fa is described below

commit 7e3d7fafafd7574acbe8ccf1c1a6a4791987c688
Author: Randall Meyer <rr...@apache.org>
AuthorDate: Fri Apr 23 13:51:49 2021 -0700

    if transaction status non-success, bypass intercept plugin (#7724)
    
    Don't allow the generator or statichit plugin to intercept the transaction
    if a prior plugin has changed the transaction status to something non-success.
    
    (plus cleanup)
---
 plugins/experimental/slice/slice.cc         | 4 ++--
 plugins/experimental/statichit/statichit.cc | 6 ++++++
 plugins/generator/generator.cc              | 6 ++++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/plugins/experimental/slice/slice.cc b/plugins/experimental/slice/slice.cc
index dcb63b8..f25e6bb 100644
--- a/plugins/experimental/slice/slice.cc
+++ b/plugins/experimental/slice/slice.cc
@@ -46,8 +46,8 @@ read_request(TSHttpTxn txnp, Config *const config)
     if (!header.hasKey(SLICER_MIME_FIELD_INFO, SLICER_MIME_LEN_INFO)) {
       // check if any previous plugin has monkeyed with the transaction status
       TSHttpStatus const txnstat = TSHttpTxnStatusGet(txnp);
-      if (0 != static_cast<int>(txnstat)) {
-        DEBUG_LOG("txn status change detected (%d), skipping plugin\n", (int)txnstat);
+      if (TS_HTTP_STATUS_NONE != txnstat) {
+        DEBUG_LOG("txn status change detected (%d), skipping plugin\n", static_cast<int>(txnstat));
         return false;
       }
 
diff --git a/plugins/experimental/statichit/statichit.cc b/plugins/experimental/statichit/statichit.cc
index 0926284..4c5c6d4 100644
--- a/plugins/experimental/statichit/statichit.cc
+++ b/plugins/experimental/statichit/statichit.cc
@@ -563,6 +563,12 @@ TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbu
 TSRemapStatus
 TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
 {
+  const TSHttpStatus txnstat = TSHttpTxnStatusGet(rh);
+  if (txnstat != TS_HTTP_STATUS_NONE && txnstat != TS_HTTP_STATUS_OK) {
+    VDEBUG("transaction status_code=%d already set; skipping processing", static_cast<int>(txnstat));
+    return TSREMAP_NO_REMAP;
+  }
+
   StaticHitConfig *cfg = static_cast<StaticHitConfig *>(ih);
 
   if (!cfg) {
diff --git a/plugins/generator/generator.cc b/plugins/generator/generator.cc
index e33681c..c6d018e 100644
--- a/plugins/generator/generator.cc
+++ b/plugins/generator/generator.cc
@@ -732,6 +732,12 @@ TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbu
 TSRemapStatus
 TSRemapDoRemap(void * /* ih */, TSHttpTxn txn, TSRemapRequestInfo *rri)
 {
+  const TSHttpStatus txnstat = TSHttpTxnStatusGet(txn);
+  if (txnstat != TS_HTTP_STATUS_NONE && txnstat != TS_HTTP_STATUS_OK) {
+    VDEBUG("transaction status_code=%d already set; skipping processing", static_cast<int>(txnstat));
+    return TSREMAP_NO_REMAP;
+  }
+
   // Check if we should turn off the cache before doing anything else ...
   CheckCacheable(txn, rri->requestUrl, rri->requestBufp);
   TSHttpTxnHookAdd(txn, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, TxnHook);