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

bcall 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 f35bc79  Separate mutex of Http2ClientSession and Http2Stream
f35bc79 is described below

commit f35bc7902438abc9a69515cb9f616193aa1cf6b2
Author: Masaori Koshiba <masa...@apache.org>
AuthorDate: Wed Feb 21 16:00:14 2018 +0900

    Separate mutex of Http2ClientSession and Http2Stream
    
    When parent selection feature is enabled, TS starts dns reverse lookup on 
every transaction.
    With HTTP/2, HostDBProcessor::getby() is called simultaneously and lock 
contention starts.
    This serialize the transactions of HTTP/2.
---
 proxy/http2/Http2ConnectionState.cc |  6 +++++-
 proxy/http2/Http2Stream.cc          | 12 +++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/proxy/http2/Http2ConnectionState.cc 
b/proxy/http2/Http2ConnectionState.cc
index 99bef1f..7c16939 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -716,6 +716,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const 
Http2Frame &frame)
     ssize_t wnd = std::min(cstate.client_rwnd, stream->client_rwnd);
 
     if (!stream->is_closed() && stream->get_state() == 
Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE && wnd > 0) {
+      SCOPED_MUTEX_LOCK(lock, stream->mutex, this_ethread());
       stream->restart_sending();
     }
   }
@@ -1054,7 +1055,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, 
Http2Error &error)
   ++total_client_streams_count;
 
   new_stream->set_parent(ua_session);
-  new_stream->mutex                     = ua_session->mutex;
+  new_stream->mutex                     = new_ProxyMutex();
   new_stream->is_first_transaction_flag = get_stream_requests() == 0;
   increment_stream_requests();
   ua_session->get_netvc()->add_to_active_queue();
@@ -1096,6 +1097,7 @@ Http2ConnectionState::restart_streams()
       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) {
+        SCOPED_MUTEX_LOCK(lock, s->mutex, this_ethread());
         s->restart_sending();
       }
       ink_assert(s != next);
@@ -1103,6 +1105,7 @@ Http2ConnectionState::restart_streams()
     }
     if (!s->is_closed() && s->get_state() == 
Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE &&
         std::min(this->client_rwnd, s->client_rwnd) > 0) {
+      SCOPED_MUTEX_LOCK(lock, s->mutex, this_ethread());
       s->restart_sending();
     }
 
@@ -1220,6 +1223,7 @@ Http2ConnectionState::update_initial_rwnd(Http2WindowSize 
new_size)
 {
   // Update stream level window sizes
   for (Http2Stream *s = stream_list.head; s; s = static_cast<Http2Stream 
*>(s->link.next)) {
+    SCOPED_MUTEX_LOCK(lock, s->mutex, this_ethread());
     s->client_rwnd = new_size - 
(client_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE) - s->client_rwnd);
   }
 }
diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc
index 372ea06..9232ed8 100644
--- a/proxy/http2/Http2Stream.cc
+++ b/proxy/http2/Http2Stream.cc
@@ -597,15 +597,18 @@ Http2Stream::update_write_request(IOBufferReader 
*buf_reader, int64_t write_len,
         int len;
         const char *value = field->value_get(&len);
         if (memcmp(HTTP_VALUE_CLOSE, value, HTTP_LEN_CLOSE) == 0) {
-          SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
+          SCOPED_MUTEX_LOCK(lock, parent->connection_state.mutex, 
this_ethread());
           if (parent->connection_state.get_shutdown_state() == 
HTTP2_SHUTDOWN_NONE) {
             
parent->connection_state.set_shutdown_state(HTTP2_SHUTDOWN_NOT_INITIATED);
           }
         }
       }
 
-      // Send the response header back
-      parent->connection_state.send_headers_frame(this);
+      {
+        SCOPED_MUTEX_LOCK(lock, parent->connection_state.mutex, 
this_ethread());
+        // Send the response header back
+        parent->connection_state.send_headers_frame(this);
+      }
 
       // See if the response is chunked.  Set up the dechunking logic if it is
       // Make sure to check if the chunk is complete and signal appropriately
@@ -668,6 +671,7 @@ void
 Http2Stream::push_promise(URL &url, const MIMEField *accept_encoding)
 {
   Http2ClientSession *parent = static_cast<Http2ClientSession 
*>(this->get_parent());
+  SCOPED_MUTEX_LOCK(lock, parent->connection_state.mutex, this_ethread());
   parent->connection_state.send_push_promise_frame(this, url, accept_encoding);
 }
 
@@ -677,10 +681,12 @@ Http2Stream::send_response_body(bool call_update)
   Http2ClientSession *parent = static_cast<Http2ClientSession 
*>(this->get_parent());
 
   if (Http2::stream_priority_enabled) {
+    SCOPED_MUTEX_LOCK(lock, parent->connection_state.mutex, this_ethread());
     parent->connection_state.schedule_stream(this);
     // signal_write_event() will be called from 
`Http2ConnectionState::send_data_frames_depends_on_priority()`
     // when write_vio is consumed
   } else {
+    SCOPED_MUTEX_LOCK(lock, parent->connection_state.mutex, this_ethread());
     parent->connection_state.send_data_frames(this);
     this->signal_write_event(call_update);
   }

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

Reply via email to