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

Method update_write_request

src/proxy/http2/Http2Stream.cc:802–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

800}
801
802void
803Http2Stream::update_write_request(bool call_update)
804{
805 if (!this->is_state_writeable() || closed || _proxy_ssn == nullptr || write_vio.mutex == nullptr ||
806 write_vio.get_reader() == nullptr || this->_send_reader == nullptr) {
807 return;
808 }
809
810 if (!this->_switch_thread_if_not_on_right_thread(VC_EVENT_WRITE_READY, nullptr)) {
811 // Not on the right thread
812 return;
813 }
814 ink_release_assert(this->_thread == this_ethread());
815
816 Http2StreamDebug("update_write_request parse_done=%d", parsing_header_done);
817
818 Http2ConnectionState &connection_state = this->get_connection_state();
819
820 SCOPED_MUTEX_LOCK(lock, write_vio.mutex, this_ethread());
821
822 IOBufferReader *vio_reader = write_vio.get_reader();
823
824 if (write_vio.ntodo() > 0 && (!vio_reader->is_read_avail_more_than(0))) {
825 Http2StreamDebug("update_write_request give up without doing anything ntodo=%" PRId64 " is_read_avail=%d client_window=%zd"
826 " session_window=%zd",
827 write_vio.ntodo(), vio_reader->is_read_avail_more_than(0), _peer_rwnd,
828 this->get_connection_state().get_peer_rwnd());
829 return;
830 }
831
832 // Process the new data
833 if (!this->parsing_header_done) {
834 // Still parsing the request or response header
835 int bytes_used = 0;
836 int state;
837 if (this->is_outbound_connection()) {
838 state = this->_send_header.parse_req(&http_parser, this->_send_reader, &bytes_used, false);
839 } else {
840 state = this->_send_header.parse_resp(&http_parser, this->_send_reader, &bytes_used, false);
841 }
842 // HTTPHdr::parse_resp() consumed the send_reader in above
843 write_vio.ndone += bytes_used;
844
845 switch (state) {
846 case PARSE_RESULT_DONE: {
847 this->parsing_header_done = true;
848 Http2StreamDebug("update_write_request parsing done, read %d bytes", bytes_used);
849
850 // Schedule session shutdown if response header has "Connection: close"
851 MIMEField *field = this->_send_header.field_find(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION);
852 if (field) {
853 auto value{field->value_get()};
854 if (value == std::string_view{HTTP_VALUE_CLOSE, static_cast<std::string_view::size_type>(HTTP_LEN_CLOSE)}) {
855 SCOPED_MUTEX_LOCK(lock, _proxy_ssn->mutex, this_ethread());
856 if (connection_state.get_shutdown_state() == HTTP2_SHUTDOWN_NONE) {
857 connection_state.set_shutdown_state(HTTP2_SHUTDOWN_NOT_INITIATED, Http2ErrorCode::HTTP2_ERROR_NO_ERROR);
858 }
859 }

Callers 2

main_event_handlerMethod · 0.95
restart_sendingMethod · 0.95

Calls 15

is_state_writeableMethod · 0.95
signal_write_eventMethod · 0.95
send_bodyMethod · 0.95
this_ethreadFunction · 0.85
http_parser_clearFunction · 0.85
http_parser_initFunction · 0.85
get_readerMethod · 0.80
ntodoMethod · 0.80
field_findMethod · 0.80

Tested by

no test coverage detected