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 2019/02/11 19:46:33 UTC

[trafficserver] branch 8.0.x updated: Mark H2 connection inactive only if it is NOT shutting down

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

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


The following commit(s) were added to refs/heads/8.0.x by this push:
     new 6ae6ff2  Mark H2 connection inactive only if it is NOT shutting down
6ae6ff2 is described below

commit 6ae6ff202a664e0e5cf296a930c8697e633601ee
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Feb 6 15:45:53 2019 +0900

    Mark H2 connection inactive only if it is NOT shutting down
    
    Prior this change, HTTP/2 connection is marked as inactive regardless it is shutting down or not.
    
    (cherry picked from commit a4227747277759c27c63ba948d96fbd6204dc8db)
---
 proxy/http2/Http2ClientSession.cc   |  2 ++
 proxy/http2/Http2ConnectionState.cc | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index 18b671e..7250c9b 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -275,6 +275,8 @@ Http2ClientSession::do_io_close(int alerrno)
     SCOPED_MUTEX_LOCK(lock, this->connection_state.mutex, this_ethread());
     this->connection_state.release_stream(nullptr);
   }
+
+  this->clear_session_active();
 }
 
 void
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 2587a89..37c35e2 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -1245,14 +1245,7 @@ Http2ConnectionState::release_stream(Http2Stream *stream)
   SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
   if (this->ua_session) {
     ink_assert(this->mutex == ua_session->mutex);
-    // If the number of clients is 0 and ua_session is active, then mark the connection as inactive
-    if (total_client_streams_count == 0 && ua_session->is_active()) {
-      ua_session->clear_session_active();
-      UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
-      if (vc && vc->active_timeout_in == 0) {
-        vc->add_to_keep_alive_queue();
-      }
-    }
+
     if (total_client_streams_count == 0) {
       if (fini_received) {
         // We were shutting down, go ahead and terminate the session
@@ -1265,6 +1258,15 @@ Http2ConnectionState::release_stream(Http2Stream *stream)
         // ua_session = nullptr;
       } else if (shutdown_state == HTTP2_SHUTDOWN_IN_PROGRESS && fini_event == nullptr) {
         fini_event = this_ethread()->schedule_imm_local((Continuation *)this, HTTP2_SESSION_EVENT_FINI);
+      } else if (ua_session->is_active()) {
+        // If the number of clients is 0, HTTP2_SESSION_EVENT_FINI is not received or sent, and ua_session is active,
+        // then mark the connection as inactive
+        ua_session->clear_session_active();
+        UnixNetVConnection *vc = static_cast<UnixNetVConnection *>(ua_session->get_netvc());
+        if (vc && vc->active_timeout_in == 0) {
+          // With heavy traffic, ua_session could be destroyed. Do not touch ua_session after this.
+          vc->add_to_keep_alive_queue();
+        }
       } else {
         schedule_zombie_event();
       }