Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions proxy/http2/Http2CommonSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,20 @@ Http2CommonSession::do_process_frame_read(int event, VIO *vio, bool inside_frame
bool
Http2CommonSession::_should_do_something_else()
{
if (this->_interrupt_reading_frames) {
this->_interrupt_reading_frames = false;
return true;
}
// Do something else every 128 incoming frames if connection state isn't closed
return (this->_n_frame_read & 0x7F) == 0 && !connection_state.is_state_closed();
}

void
Http2CommonSession::interrupt_reading_frames()
{
this->_interrupt_reading_frames = true;
}

int64_t
Http2CommonSession::write_avail()
{
Expand Down
5 changes: 5 additions & 0 deletions proxy/http2/Http2CommonSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class Http2CommonSession

virtual void set_no_activity_timeout() = 0;

void interrupt_reading_frames();

///////////////////
// Variables
Http2ConnectionState connection_state;
Expand Down Expand Up @@ -166,6 +168,9 @@ class Http2CommonSession

int64_t read_from_early_data = 0;
bool cur_frame_from_early_data = false;

private:
bool _interrupt_reading_frames = false;
};

///////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions proxy/http2/Http2ConnectionState.cc
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ Http2ConnectionState::rcv_headers_frame(const Http2Frame &frame)
stream->send_request(*this);
}
}
// Give a chance to send response before reading next frame.
this->session->interrupt_reading_frames();
} else {
// NOTE: Expect CONTINUATION Frame. Do NOT change state of stream or decode
// Header Blocks.
Expand Down Expand Up @@ -1047,6 +1049,8 @@ Http2ConnectionState::rcv_continuation_frame(const Http2Frame &frame)
stream->new_transaction(frame.is_from_early_data());
// Send request header to SM
stream->send_request(*this);
// Give a chance to send response before reading next frame.
this->session->interrupt_reading_frames();
} else {
// NOTE: Expect another CONTINUATION Frame. Do nothing.
Http2StreamDebug(this->session, stream_id, "No END_HEADERS flag, expecting CONTINUATION frame");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ sessions:
- name: tcp
- name: ip
version: 4
keep-connection-open: 2s
transactions:
- client-request:
frames:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ sessions:
- name: tcp
- name: ip
version: 4
keep-connection-open: 2s
transactions:
- client-request:
frames:
Expand Down