You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2014/07/01 22:40:08 UTC

git commit: TS-2906: SPDY incorrectly marks streams as internal requests

Repository: trafficserver
Updated Branches:
  refs/heads/master f6b7e79fb -> c9dab54de


TS-2906: SPDY incorrectly marks streams as internal requests


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c9dab54d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c9dab54d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c9dab54d

Branch: refs/heads/master
Commit: c9dab54de8c9fff362436956b0cf69aa7dc6cb6b
Parents: f6b7e79
Author: Brian Geffon <br...@apache.org>
Authored: Tue Jul 1 13:40:00 2014 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Tue Jul 1 13:40:00 2014 -0700

----------------------------------------------------------------------
 proxy/FetchSM.cc            | 15 +++++++++++++++
 proxy/FetchSM.h             |  4 ++++
 proxy/api/ts/experimental.h |  1 +
 proxy/spdy/SpdyCallbacks.cc |  4 ++++
 4 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c9dab54d/proxy/FetchSM.cc
----------------------------------------------------------------------
diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc
index b880a9d..0372e9c 100644
--- a/proxy/FetchSM.cc
+++ b/proxy/FetchSM.cc
@@ -75,6 +75,18 @@ FetchSM::httpConnect()
   Debug(DEBUG_TAG, "[%s] calling httpconnect write", __FUNCTION__);
   http_vc = reinterpret_cast<PluginVC*>(TSHttpConnectWithPluginId(&_addr.sa, tag, id));
 
+  /*
+   * TS-2906: We need a way to unset internal request when using FetchSM, the use case for this
+   * is SPDY when it creates outgoing requests it uses FetchSM and the outgoing requests
+   * are spawned via SPDY SYN packets which are definitely not internal requests.
+   */
+  if (!is_internal_request) {
+    PluginVC* other_side = reinterpret_cast<PluginVC*>(http_vc)->get_other_side();
+    if (other_side != NULL) {
+      other_side->set_is_internal_request(false);
+    }
+  }
+
   read_vio = http_vc->do_io_read(this, INT64_MAX, resp_buffer);
   write_vio = http_vc->do_io_write(this, getReqLen() + req_content_length, req_reader);
 }
@@ -494,6 +506,9 @@ FetchSM::ext_init(Continuation *cont, TSFetchMethod method,
   // Enable stream IO automatically.
   //
   fetch_flags = (TS_FETCH_FLAGS_STREAM | flags);
+  if (fetch_flags & TS_FETCH_FLAGS_NOT_INTERNAL_REQUEST) {
+    set_internal_request(false);
+  }
 
   //
   // These options are not used when enable

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c9dab54d/proxy/FetchSM.h
----------------------------------------------------------------------
diff --git a/proxy/FetchSM.h b/proxy/FetchSM.h
index c1b94bf..0eb0922 100644
--- a/proxy/FetchSM.h
+++ b/proxy/FetchSM.h
@@ -45,6 +45,7 @@ public:
 
   void init_comm()
   {
+    is_internal_request = true;
     recursion = 0;
     req_finished = 0;
     resp_finished = 0;
@@ -120,6 +121,8 @@ public:
   void ext_write_data(const void *data, size_t len);
   void ext_set_user_data(void *data);
   void* ext_get_user_data();
+  bool get_internal_request() { return is_internal_request; }
+  void set_internal_request(bool val) { is_internal_request = val; }
 
 private:
   int InvokePlugin(int event, void*data);
@@ -160,6 +163,7 @@ private:
   bool req_finished;
   bool header_done;
   bool resp_finished;
+  bool is_internal_request;
   IpEndpoint _addr;
   int resp_is_chunked;
   int fetch_flags;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c9dab54d/proxy/api/ts/experimental.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/experimental.h b/proxy/api/ts/experimental.h
index b5742d7..ac4cd8e 100644
--- a/proxy/api/ts/experimental.h
+++ b/proxy/api/ts/experimental.h
@@ -66,6 +66,7 @@ extern "C"
     TS_FETCH_FLAGS_STREAM = 1 << 1,    // enable stream IO
     TS_FETCH_FLAGS_DECHUNK = 1 << 2,   // dechunk body content
     TS_FETCH_FLAGS_NEWLOCK = 1 << 3,   // allocate new lock for fetch sm
+    TS_FETCH_FLAGS_NOT_INTERNAL_REQUEST = 1 << 4 // Allow this fetch to be created as a non-internal request.
   } TSFetchFlags;
 
   typedef struct tsapi_fetchsm* TSFetchSM;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c9dab54d/proxy/spdy/SpdyCallbacks.cc
----------------------------------------------------------------------
diff --git a/proxy/spdy/SpdyCallbacks.cc b/proxy/spdy/SpdyCallbacks.cc
index d9fcd69..5a0564f 100644
--- a/proxy/spdy/SpdyCallbacks.cc
+++ b/proxy/spdy/SpdyCallbacks.cc
@@ -182,6 +182,10 @@ spdy_fetcher_launch(SpdyRequest *req, TSFetchMethod method)
   // HTTP content should be dechunked before packed into SPDY.
   //
   fetch_flags = TS_FETCH_FLAGS_DECHUNK;
+
+  // TS-2906: FetchSM sets requests are internal requests, we need to not do that for SPDY streams.
+  fetch_flags |= TS_FETCH_FLAGS_NOT_INTERNAL_REQUEST;
+
   req->fetch_sm = TSFetchCreate((TSCont)sm, method,
                                 url.c_str(), req->version.c_str(),
                                 client_addr, fetch_flags);