You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2024/04/18 05:50:11 UTC
(trafficserver) branch master updated: http2: Track scheduled events (#11262)
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 f6ad241eb4 http2: Track scheduled events (#11262)
f6ad241eb4 is described below
commit f6ad241eb4e87a92b5c5f21b91b5538c60574368
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Thu Apr 18 14:50:05 2024 +0900
http2: Track scheduled events (#11262)
* http2: Track scheduled events
* Handle events on state_closed
---
include/proxy/http2/Http2ConnectionState.h | 4 ++--
src/proxy/http2/Http2ConnectionState.cc | 37 +++++++++++++++++++++---------
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/include/proxy/http2/Http2ConnectionState.h b/include/proxy/http2/Http2ConnectionState.h
index 4f992de488..f88f316dc5 100644
--- a/include/proxy/http2/Http2ConnectionState.h
+++ b/include/proxy/http2/Http2ConnectionState.h
@@ -393,8 +393,6 @@ private:
// "If the END_HEADERS bit is not set, this frame MUST be followed by
// another CONTINUATION frame."
Http2StreamId continued_stream_id = 0;
- bool _priority_scheduled = false;
- bool _data_scheduled = false;
bool fini_received = false;
bool in_destroy = false;
int recursion = 0;
@@ -403,6 +401,8 @@ private:
Event *shutdown_cont_event = nullptr;
Event *fini_event = nullptr;
Event *zombie_event = nullptr;
+ Event *_priority_event = nullptr;
+ Event *_data_event = nullptr;
Event *retransmit_event = nullptr;
uint32_t configured_max_settings_frames_per_minute = 0;
diff --git a/src/proxy/http2/Http2ConnectionState.cc b/src/proxy/http2/Http2ConnectionState.cc
index 62edea507a..5ce24c5c4f 100644
--- a/src/proxy/http2/Http2ConnectionState.cc
+++ b/src/proxy/http2/Http2ConnectionState.cc
@@ -1377,6 +1377,15 @@ Http2ConnectionState::destroy()
if (zombie_event) {
zombie_event->cancel();
}
+
+ if (_priority_event) {
+ _priority_event->cancel();
+ }
+
+ if (_data_event) {
+ _data_event->cancel();
+ }
+
if (retransmit_event) {
retransmit_event->cancel();
}
@@ -1462,10 +1471,15 @@ Http2ConnectionState::main_event_handler(int event, void *edata)
ink_release_assert(zombie_event == nullptr);
} else if (edata == fini_event) {
fini_event = nullptr;
+ } else if (edata == _priority_event) {
+ _priority_event = nullptr;
+ } else if (edata == _data_event) {
+ _data_event = nullptr;
} else if (edata == retransmit_event) {
retransmit_event = nullptr;
}
++recursion;
+
switch (event) {
// Finalize HTTP/2 Connection
case HTTP2_SESSION_EVENT_FINI: {
@@ -1483,14 +1497,12 @@ Http2ConnectionState::main_event_handler(int event, void *edata)
REMEMBER(event, this->recursion);
SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
send_data_frames_depends_on_priority();
- _priority_scheduled = false;
} break;
case HTTP2_SESSION_EVENT_DATA: {
REMEMBER(event, this->recursion);
SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
this->restart_streams();
- _data_scheduled = false;
} break;
case HTTP2_SESSION_EVENT_XMIT: {
@@ -1561,6 +1573,10 @@ Http2ConnectionState::state_closed(int event, void *edata)
ink_release_assert(zombie_event == nullptr);
} else if (edata == fini_event) {
fini_event = nullptr;
+ } else if (edata == _priority_event) {
+ _priority_event = nullptr;
+ } else if (edata == _data_event) {
+ _data_event = nullptr;
} else if (edata == shutdown_cont_event) {
shutdown_cont_event = nullptr;
} else if (edata == retransmit_event) {
@@ -2077,11 +2093,9 @@ Http2ConnectionState::schedule_stream_to_send_priority_frames(Http2Stream *strea
SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
dependency_tree->activate(node);
- if (!_priority_scheduled) {
- _priority_scheduled = true;
-
+ if (_priority_event == nullptr) {
SET_HANDLER(&Http2ConnectionState::main_event_handler);
- this_ethread()->schedule_imm_local(static_cast<Continuation *>(this), HTTP2_SESSION_EVENT_PRIO);
+ _priority_event = this_ethread()->schedule_imm_local(static_cast<Continuation *>(this), HTTP2_SESSION_EVENT_PRIO);
}
}
@@ -2092,11 +2106,9 @@ Http2ConnectionState::schedule_stream_to_send_data_frames(Http2Stream *stream)
SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
- if (!_data_scheduled) {
- _data_scheduled = true;
-
+ if (_data_event == nullptr) {
SET_HANDLER(&Http2ConnectionState::main_event_handler);
- this_ethread()->schedule_in(static_cast<Continuation *>(this), HRTIME_MSECOND, HTTP2_SESSION_EVENT_DATA);
+ _data_event = this_ethread()->schedule_in(static_cast<Continuation *>(this), HRTIME_MSECOND, HTTP2_SESSION_EVENT_DATA);
}
}
@@ -2165,7 +2177,10 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
break;
}
- this_ethread()->schedule_imm_local(static_cast<Continuation *>(this), HTTP2_SESSION_EVENT_PRIO);
+ if (_priority_event == nullptr) {
+ _priority_event = this_ethread()->schedule_imm_local(static_cast<Continuation *>(this), HTTP2_SESSION_EVENT_PRIO);
+ }
+
return;
}