MCPcopy Create free account
hub / github.com/apache/trafficserver / main_event_handler

Method main_event_handler

src/proxy/http2/Http2Stream.cc:172–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172int
173Http2Stream::main_event_handler(int event, void *edata)
174{
175 SCOPED_MUTEX_LOCK(lock, this->mutex, this_ethread());
176 REMEMBER(event, this->reentrancy_count);
177
178 if (!this->_switch_thread_if_not_on_right_thread(event, edata)) {
179 // Not on the right thread
180 return 0;
181 }
182 ink_release_assert(this->_thread == this_ethread());
183
184 Event *e = static_cast<Event *>(edata);
185 reentrancy_count++;
186 if (e == _read_vio_event) {
187 _read_vio_event = nullptr;
188 this->signal_read_event(e->callback_event);
189 reentrancy_count--;
190 return 0;
191 } else if (e == _write_vio_event) {
192 _write_vio_event = nullptr;
193 this->signal_write_event(e->callback_event);
194 reentrancy_count--;
195 return 0;
196 } else if (e == cross_thread_event) {
197 cross_thread_event = nullptr;
198 } else if (e == read_event) {
199 read_event = nullptr;
200 } else if (e == write_event) {
201 write_event = nullptr;
202 }
203
204 switch (event) {
205 case VC_EVENT_ACTIVE_TIMEOUT:
206 case VC_EVENT_INACTIVITY_TIMEOUT:
207 if (_sm == nullptr && closed != true) {
208 // TIMEOUT without HttpSM - assuming incomplete header timeout
209 Http2StreamDebug("timeout event=%d", event);
210
211 ip_port_text_buffer ipb;
212 const char *remote_ip = ats_ip_ntop(this->_proxy_ssn->get_remote_addr(), ipb, sizeof(ipb));
213
214 Error("HTTP/2 stream error timeout remote_ip=%s session_id=%" PRId64 " stream_id=%u event=%d", remote_ip,
215 this->_proxy_ssn->connection_id(), this->_id, event);
216
217 // Close stream
218 do_io_close();
219 terminate_stream = true;
220
221 // Close connection because this stream doesn't read HEADERS/CONTINUATION frames anymore that makes HPACK dynamic table
222 // out of sync.
223 Http2ConnectionState &connection_state = get_connection_state();
224 {
225 SCOPED_MUTEX_LOCK(lock, connection_state.mutex, this_ethread());
226 Http2Error error(Http2ErrorClass::HTTP2_ERROR_CLASS_CONNECTION, Http2ErrorCode::HTTP2_ERROR_COMPRESSION_ERROR,
227 "stream timeout");
228 connection_state.handleEvent(HTTP2_SESSION_EVENT_ERROR, &error);
229 }

Callers

nothing calls this directly

Calls 13

signal_read_eventMethod · 0.95
signal_write_eventMethod · 0.95
update_write_requestMethod · 0.95
update_read_requestMethod · 0.95
this_ethreadFunction · 0.85
ntodoMethod · 0.80
update_inactivityMethod · 0.80
ats_ip_ntopFunction · 0.50
ErrorClass · 0.50
get_remote_addrMethod · 0.45
connection_idMethod · 0.45

Tested by

no test coverage detected