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

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


The following commit(s) were added to refs/heads/7.1.x by this push:
     new 74f2cca  fix instability caused by HTTP2_SESSION_EVENT_FINI
74f2cca is described below

commit 74f2cca056b541f4782bcfab676a487b02ddd2de
Author: Fei Deng <[email protected]>
AuthorDate: Thu Mar 1 13:58:16 2018 -0600

    fix instability caused by HTTP2_SESSION_EVENT_FINI
    
    (cherry picked from commit 36a28db62d36f248f9b003bab84aaadb370809fe)
---
 proxy/http2/Http2ConnectionState.cc | 24 +++++++++++++++++++-----
 proxy/http2/Http2ConnectionState.h  |  8 +++++++-
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/proxy/http2/Http2ConnectionState.cc 
b/proxy/http2/Http2ConnectionState.cc
index 992113b..22a6395 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -836,6 +836,9 @@ static const http2_frame_dispatch 
frame_handlers[HTTP2_FRAME_TYPE_MAX] = {
 int
 Http2ConnectionState::main_event_handler(int event, void *edata)
 {
+  if (edata == fini_event) {
+    fini_event = nullptr;
+  }
   ++recursion;
   switch (event) {
   // Initialize HTTP/2 Connection
@@ -910,7 +913,9 @@ Http2ConnectionState::main_event_handler(int event, void 
*edata)
         }
         this->send_goaway_frame(this->latest_streamid_in, error.code);
         this->ua_session->set_half_close_local_flag(true);
-        this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+        if (fini_event == nullptr) {
+          fini_event = this_ethread()->schedule_imm_local((Continuation 
*)this, HTTP2_SESSION_EVENT_FINI);
+        }
 
         // The streams will be cleaned up by the HTTP2_SESSION_EVENT_FINI event
         // The Http2ClientSession will shutdown because 
connection_state.is_state_closed() will be true
@@ -944,8 +949,11 @@ Http2ConnectionState::main_event_handler(int event, void 
*edata)
 }
 
 int
-Http2ConnectionState::state_closed(int /* event */, void * /* edata */)
+Http2ConnectionState::state_closed(int /* event */, void *edata)
 {
+  if (edata == fini_event) {
+    fini_event = nullptr;
+  }
   return 0;
 }
 
@@ -1410,7 +1418,9 @@ Http2ConnectionState::send_headers_frame(Http2Stream 
*stream)
   if (!stream->change_state(HTTP2_FRAME_TYPE_HEADERS, flags)) {
     this->send_goaway_frame(this->latest_streamid_in, 
Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR);
     this->ua_session->set_half_close_local_flag(true);
-    this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+    if (fini_event == nullptr) {
+      fini_event = this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+    }
 
     h2_hdr.destroy();
     ats_free(buf);
@@ -1587,7 +1597,9 @@ Http2ConnectionState::send_rst_stream_frame(Http2StreamId 
id, Http2ErrorCode ec)
     if (!stream->change_state(HTTP2_FRAME_TYPE_RST_STREAM, 0)) {
       this->send_goaway_frame(this->latest_streamid_in, 
Http2ErrorCode::HTTP2_ERROR_PROTOCOL_ERROR);
       this->ua_session->set_half_close_local_flag(true);
-      this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+      if (fini_event == nullptr) {
+        fini_event = this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+      }
 
       return;
     }
@@ -1623,7 +1635,9 @@ Http2ConnectionState::send_settings_frame(const 
Http2ConnectionSettings &new_set
       if (!http2_write_settings(param, iov)) {
         this->send_goaway_frame(this->latest_streamid_in, 
Http2ErrorCode::HTTP2_ERROR_INTERNAL_ERROR);
         this->ua_session->set_half_close_local_flag(true);
-        this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_FINI);
+        if (fini_event == nullptr) {
+          fini_event = this_ethread()->schedule_imm_local((Continuation 
*)this, HTTP2_SESSION_EVENT_FINI);
+        }
 
         return;
       }
diff --git a/proxy/http2/Http2ConnectionState.h 
b/proxy/http2/Http2ConnectionState.h
index 02d5274..b0a5f5f 100644
--- a/proxy/http2/Http2ConnectionState.h
+++ b/proxy/http2/Http2ConnectionState.h
@@ -127,7 +127,8 @@ public:
       continued_stream_id(0),
       _scheduled(false),
       fini_received(false),
-      recursion(0)
+      recursion(0),
+      fini_event(nullptr)
   {
     SET_HANDLER(&Http2ConnectionState::main_event_handler);
   }
@@ -166,6 +167,10 @@ public:
 
     delete dependency_tree;
     this->ua_session = nullptr;
+
+    if (fini_event) {
+      fini_event->cancel();
+    }
   }
 
   // Event handlers
@@ -305,6 +310,7 @@ private:
   bool _scheduled;
   bool fini_received;
   int recursion;
+  Event *fini_event;
 };
 
 #endif // __HTTP2_CONNECTION_STATE_H__

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to