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

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


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 3ca4f5d2d6 http2: Track scheduled events (#11262) (#13377)
3ca4f5d2d6 is described below

commit 3ca4f5d2d60ac3487afd7d2d77379c9e6a56757e
Author: Brian Neradt <[email protected]>
AuthorDate: Wed Jul 15 11:41:04 2026 -0500

    http2: Track scheduled events (#11262) (#13377)
    
    * http2: Track scheduled events
    
    * Handle events on state_closed
    
    Co-authored-by: Masaori Koshiba <[email protected]>
---
 proxy/http2/Http2ConnectionState.cc | 18 +++++++++++++++---
 proxy/http2/Http2ConnectionState.h  |  2 ++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/proxy/http2/Http2ConnectionState.cc 
b/proxy/http2/Http2ConnectionState.cc
index 10266c3dac..6749e84a85 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -36,8 +36,9 @@
 #include "tscpp/util/PostScript.h"
 #include "tscpp/util/LocalBuffer.h"
 
-#include <sstream>
+#include <algorithm>
 #include <numeric>
+#include <sstream>
 
 #define REMEMBER(e, r)                                     \
   {                                                        \
@@ -1219,6 +1220,9 @@ Http2ConnectionState::destroy()
   if (zombie_event) {
     zombie_event->cancel();
   }
+  for (auto *event : _xmit_events) {
+    event->cancel();
+  }
   // release the mutex after the events are cancelled and sessions are 
destroyed.
   mutex = nullptr; // magic happens - assigning to nullptr frees the ProxyMutex
 }
@@ -1302,6 +1306,10 @@ Http2ConnectionState::main_event_handler(int event, void 
*edata)
   } else if (edata == fini_event) {
     fini_event = nullptr;
   }
+  if (auto const xmit_event = std::find(_xmit_events.begin(), 
_xmit_events.end(), static_cast<Event *>(edata));
+      xmit_event != _xmit_events.end()) {
+    _xmit_events.erase(xmit_event);
+  }
   ++recursion;
   switch (event) {
   // Finalize HTTP/2 Connection
@@ -1405,6 +1413,10 @@ Http2ConnectionState::state_closed(int event, void 
*edata)
   } else if (edata == shutdown_cont_event) {
     shutdown_cont_event = nullptr;
   }
+  if (auto const xmit_event = std::find(_xmit_events.begin(), 
_xmit_events.end(), static_cast<Event *>(edata));
+      xmit_event != _xmit_events.end()) {
+    _xmit_events.erase(xmit_event);
+  }
   return 0;
 }
 
@@ -1724,7 +1736,7 @@ Http2ConnectionState::schedule_stream(Http2Stream *stream)
     _scheduled = true;
 
     SET_HANDLER(&Http2ConnectionState::main_event_handler);
-    this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_XMIT);
+    _xmit_events.push_back(this_ethread()->schedule_imm_local((Continuation 
*)this, HTTP2_SESSION_EVENT_XMIT));
   }
 }
 
@@ -1769,7 +1781,7 @@ 
Http2ConnectionState::send_data_frames_depends_on_priority()
     break;
   }
 
-  this_ethread()->schedule_imm_local((Continuation *)this, 
HTTP2_SESSION_EVENT_XMIT);
+  _xmit_events.push_back(this_ethread()->schedule_imm_local((Continuation 
*)this, HTTP2_SESSION_EVENT_XMIT));
   return;
 }
 
diff --git a/proxy/http2/Http2ConnectionState.h 
b/proxy/http2/Http2ConnectionState.h
index fff7763f2a..0cd88d4608 100644
--- a/proxy/http2/Http2ConnectionState.h
+++ b/proxy/http2/Http2ConnectionState.h
@@ -24,6 +24,7 @@
 #pragma once
 
 #include <atomic>
+#include <vector>
 
 #include "NetTimeout.h"
 
@@ -242,6 +243,7 @@ private:
   Event *shutdown_cont_event        = nullptr;
   Event *fini_event                 = nullptr;
   Event *zombie_event               = nullptr;
+  std::vector<Event *> _xmit_events;
 };
 
 ///////////////////////////////////////////////

Reply via email to