You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2022/02/22 21:18:24 UTC

[trafficserver] branch 9.1.x updated: Make sure each remap rule gets its own continuation (#8675)

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

zwoop pushed a commit to branch 9.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.1.x by this push:
     new 8b09eb3  Make sure each remap rule gets its own continuation (#8675)
8b09eb3 is described below

commit 8b09eb342534864d03d47fdec6ecbf90a61a831d
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Thu Feb 17 13:23:33 2022 -0700

    Make sure each remap rule gets its own continuation (#8675)
    
    (cherry picked from commit eaf9848fd539d7f42218374b9f65754df943956e)
---
 plugins/experimental/statichit/statichit.cc | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/plugins/experimental/statichit/statichit.cc b/plugins/experimental/statichit/statichit.cc
index 4cca0f4..09bc686 100644
--- a/plugins/experimental/statichit/statichit.cc
+++ b/plugins/experimental/statichit/statichit.cc
@@ -55,8 +55,6 @@ constexpr char PLUGIN[] = "statichit";
   VDEBUG("vio=%p vio.cont=%p, vio.cont.data=%p, vio.vc=%p " fmt, (vio), TSVIOContGet(vio), TSContDataGet(TSVIOContGet(vio)), \
          TSVIOVConnGet(vio), ##__VA_ARGS__)
 
-static TSCont TxnHook;
-
 static int StatCountBytes     = -1;
 static int StatCountResponses = -1;
 
@@ -69,7 +67,7 @@ struct StaticHitConfig {
   {
   }
 
-  ~StaticHitConfig() {}
+  ~StaticHitConfig() { TSContDestroy(cont); }
 
   std::string filePath;
   std::string mimeType;
@@ -79,6 +77,8 @@ struct StaticHitConfig {
   int maxAge      = 0;
 
   bool disableExact = false;
+
+  TSCont cont;
 };
 
 struct StaticHitRequest;
@@ -550,8 +550,6 @@ done:
 TSReturnCode
 TSRemapInit(TSRemapInterface * /* api_info */, char * /* errbuf */, int /* errbuf_size */)
 {
-  TxnHook = TSContCreate(StaticHitTxnHook, nullptr);
-
   if (TSStatFindName("statichit.response_bytes", &StatCountBytes) == TS_ERROR) {
     StatCountBytes = TSStatCreate("statichit.response_bytes", TS_RECORDDATATYPE_COUNTER, TS_STAT_NON_PERSISTENT, TS_STAT_SYNC_SUM);
   }
@@ -595,9 +593,8 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
     TSHttpTxnConfigIntSet(rh, TS_CONFIG_HTTP_CACHE_HTTP, 0);
     StaticHitSetupIntercept(static_cast<StaticHitConfig *>(ih), rh);
   } else {
-    TSHttpTxnHookAdd(rh, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, TxnHook);
+    TSHttpTxnHookAdd(rh, TS_HTTP_CACHE_LOOKUP_COMPLETE_HOOK, static_cast<StaticHitConfig *>(ih)->cont);
   }
-  TSContDataSet(TxnHook, ih);
 
   return TSREMAP_NO_REMAP; // This plugin never rewrites anything.
 }
@@ -673,6 +670,10 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE
     tc->successCode = successCode;
   }
 
+  // Finally, create the continuation to use for this remap rule, tracking the config as cont data.
+  tc->cont = TSContCreate(StaticHitTxnHook, nullptr);
+  TSContDataSet(tc->cont, tc);
+
   *ih = static_cast<void *>(tc);
 
   return TS_SUCCESS;