trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kic...@apache.org
Subject [trafficserver] branch master updated: to only fix the SELCT_ALT hook
Date Fri, 09 Feb 2018 04:40:55 GMT
This is an automated email from the ASF dual-hosted git repository.

kichan 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 ec3ed32  to only fix the SELCT_ALT hook
ec3ed32 is described below

commit ec3ed32c9b5928bdcd16791b36f19fe87c74cf43
Author: Christopher Hassell <christopher_hassell@comcast.com>
AuthorDate: Thu Oct 26 12:36:17 2017 -0600

    to only fix the SELCT_ALT hook
---
 lib/cppapi/GlobalPlugin.cc             |  9 ++++++++-
 lib/cppapi/include/atscppapi/Plugin.h  |  7 ++-----
 lib/cppapi/include/atscppapi/Request.h |  6 ++++++
 lib/cppapi/include/utils_internal.h    |  1 +
 lib/cppapi/utils_internal.cc           | 25 +++++++++++++++++++++----
 5 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lib/cppapi/GlobalPlugin.cc b/lib/cppapi/GlobalPlugin.cc
index e8a2df8..151dbf1 100644
--- a/lib/cppapi/GlobalPlugin.cc
+++ b/lib/cppapi/GlobalPlugin.cc
@@ -48,8 +48,15 @@ namespace
 static int
 handleGlobalPluginEvents(TSCont cont, TSEvent event, void *edata)
 {
-  TSHttpTxn txn            = static_cast<TSHttpTxn>(edata);
   GlobalPluginState *state = static_cast<GlobalPluginState *>(TSContDataGet(cont));
+
+  if (event == TS_EVENT_HTTP_SELECT_ALT) {
+    TSHttpAltInfo alt = static_cast<TSHttpAltInfo>(edata);
+    utils::internal::invokePluginForEvent(state->global_plugin_, alt, event);
+    return 0;
+  }
+
+  TSHttpTxn txn = static_cast<TSHttpTxn>(edata);
   if (state->ignore_internal_transactions_ && TSHttpTxnIsInternal(txn)) {
     LOG_DEBUG("Ignoring event %d on internal transaction %p for global plugin %p", event,
txn, state->global_plugin_);
     TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
diff --git a/lib/cppapi/include/atscppapi/Plugin.h b/lib/cppapi/include/atscppapi/Plugin.h
index 22cd377..8d596a4 100644
--- a/lib/cppapi/include/atscppapi/Plugin.h
+++ b/lib/cppapi/include/atscppapi/Plugin.h
@@ -27,6 +27,7 @@
 #ifndef ATSCPPAPI_PLUGIN_H_
 #define ATSCPPAPI_PLUGIN_H_
 
+#include <atscppapi/Request.h>
 #include <atscppapi/Transaction.h>
 #include <atscppapi/noncopyable.h>
 
@@ -146,11 +147,7 @@ public:
   /**
    * This method must be implemented when you hook HOOK_SELECT_ALT
    */
-  virtual void
-  handleSelectAlt(Transaction &transaction)
-  {
-    transaction.resume();
-  };
+  virtual void handleSelectAlt(const Request &clientReq, const Request &cachedReq,
const Response &cachedResp){};
 
   virtual ~Plugin(){};
 
diff --git a/lib/cppapi/include/atscppapi/Request.h b/lib/cppapi/include/atscppapi/Request.h
index 37990ee..1d9e49e 100644
--- a/lib/cppapi/include/atscppapi/Request.h
+++ b/lib/cppapi/include/atscppapi/Request.h
@@ -31,6 +31,11 @@
 
 namespace atscppapi
 {
+namespace utils
+{
+  class internal;
+}
+
 class Transaction;
 struct RequestState;
 
@@ -80,6 +85,7 @@ private:
   void reset();
   friend class Transaction;
   friend class ClientRequest;
+  friend class utils::internal;
 };
 }
 
diff --git a/lib/cppapi/include/utils_internal.h b/lib/cppapi/include/utils_internal.h
index 4e67587..67a076b 100644
--- a/lib/cppapi/include/utils_internal.h
+++ b/lib/cppapi/include/utils_internal.h
@@ -53,6 +53,7 @@ namespace utils
     static TSHttpHookID convertInternalTransformationTypeToTsHook(TransformationPlugin::Type
type);
     static void invokePluginForEvent(TransactionPlugin *, TSHttpTxn, TSEvent);
     static void invokePluginForEvent(GlobalPlugin *, TSHttpTxn, TSEvent);
+    static void invokePluginForEvent(GlobalPlugin *, TSHttpAltInfo, TSEvent);
     static HttpVersion getHttpVersion(TSMBuffer hdr_buf, TSMLoc hdr_loc);
     static void initTransactionManagement();
     static std::string consumeFromTSIOBufferReader(TSIOBufferReader);
diff --git a/lib/cppapi/utils_internal.cc b/lib/cppapi/utils_internal.cc
index 953f401..c0165c5 100644
--- a/lib/cppapi/utils_internal.cc
+++ b/lib/cppapi/utils_internal.cc
@@ -141,10 +141,6 @@ void inline invokePluginForEvent(Plugin *plugin, TSHttpTxn ats_txn_handle,
TSEve
   case TS_EVENT_HTTP_CACHE_LOOKUP_COMPLETE:
     plugin->handleReadCacheLookupComplete(transaction);
     break;
-  case TS_EVENT_HTTP_SELECT_ALT:
-    plugin->handleSelectAlt(transaction);
-    break;
-
   default:
     assert(false); /* we should never get here */
     break;
@@ -232,6 +228,27 @@ utils::internal::invokePluginForEvent(GlobalPlugin *plugin, TSHttpTxn
ats_txn_ha
   ::invokePluginForEvent(static_cast<Plugin *>(plugin), ats_txn_handle, event);
 }
 
+void
+utils::internal::invokePluginForEvent(GlobalPlugin *plugin, TSHttpAltInfo altinfo_handle,
TSEvent event)
+{
+  TSMBuffer hdr_buf;
+  TSMLoc hdr_loc;
+
+  assert(event == TS_EVENT_HTTP_SELECT_ALT);
+
+  TSHttpAltInfoClientReqGet(altinfo_handle, &hdr_buf, &hdr_loc);
+  const Request clientReq(hdr_buf, hdr_loc); // no MLocRelease needed
+
+  TSHttpAltInfoCachedReqGet(altinfo_handle, &hdr_buf, &hdr_loc);
+  const Request cachedReq(hdr_buf, hdr_loc); // no MLocRelease needed
+
+  TSHttpAltInfoCachedRespGet(altinfo_handle, &hdr_buf, &hdr_loc);
+  Response cachedResp;
+  cachedResp.init(hdr_buf, hdr_loc); // no MLocRelease needed
+
+  plugin->handleSelectAlt(clientReq, cachedReq, cachedResp);
+}
+
 std::string
 utils::internal::consumeFromTSIOBufferReader(TSIOBufferReader reader)
 {

-- 
To stop receiving notification emails like this one, please contact
kichan@apache.org.

Mime
View raw message