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

masaori 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 a422774  Mark H2 connection inactive only if it is NOT shutting down
a422774 is described below

commit a4227747277759c27c63ba948d96fbd6204dc8db
Author: Masaori Koshiba <masa...@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.
---
 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 3cc9edd..e6037fd 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -272,6 +272,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 a6843ec..45689d7 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();
       }

Reply via email to