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 2017/11/04 23:14:42 UTC

[trafficserver] branch master updated: Send data fairly on H2 streams even if stream priority is disabled

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

zwoop 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 6dcc822  Send data fairly on H2 streams even if stream priority is disabled
6dcc822 is described below

commit 6dcc822baf23b1ab69c9a2609fc4f65fd9f6c10b
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Tue Oct 31 15:52:52 2017 +0900

    Send data fairly on H2 streams even if stream priority is disabled
---
 proxy/http2/Http2ConnectionState.cc | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 6cfe32f..0cd9c3f 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1067,16 +1067,36 @@ Http2ConnectionState::find_stream(Http2StreamId id) const
 void
 Http2ConnectionState::restart_streams()
 {
-  Http2Stream *s = stream_list.head;
-
-  while (s) {
-    Http2Stream *next = static_cast<Http2Stream *>(s->link.next);
+  // This is a static variable, so it is shared in Http2ConnectionState instances and will get incremented in subsequent calls.
+  // It doesn't need to be initialized with rand() nor time(), and doesn't need to be accessed with a lock, because it doesn't need
+  // that randomness and accuracy.
+  static uint16_t starting_point = 0;
+
+  Http2Stream *s   = stream_list.head;
+  Http2Stream *end = s;
+  if (s) {
+    // Change the start point randomly
+    for (int i = starting_point % total_client_streams_count; i >= 0; --i) {
+      end = static_cast<Http2Stream *>(end->link.next ? end->link.next : stream_list.head);
+    }
+    s = static_cast<Http2Stream *>(end->link.next ? end->link.next : stream_list.head);
+
+    // Call send_response_body() for each streams
+    while (s != end) {
+      Http2Stream *next = static_cast<Http2Stream *>(s->link.next ? s->link.next : stream_list.head);
+      if (!s->is_closed() && s->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE &&
+          std::min(this->client_rwnd, s->client_rwnd) > 0) {
+        s->send_response_body();
+      }
+      ink_assert(s != next);
+      s = next;
+    }
     if (!s->is_closed() && s->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE &&
         std::min(this->client_rwnd, s->client_rwnd) > 0) {
       s->send_response_body();
     }
-    ink_assert(s != next);
-    s = next;
+
+    ++starting_point;
   }
 }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].