This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 7.1.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit da5f0840057b6dea8d0d5091334e2a5911b1a829 Author: Masaori Koshiba <masa...@apache.org> AuthorDate: Wed Feb 7 16:53:55 2018 +0900 Cleanup Http2Stream - Remove return value of Http2Stream::update_write_request(). Because return value is not used in most cases. And Http2Stream::do_io_write() can always return &write_vio where only the return value is used. - Http2Stream::update_write_request() returns immediately if there're no data to proceed - Make Http2Stream::send_response_body() private (cherry picked from commit 17f0e83620bf3ab2604e73fc7cd13d9e048513eb) Conflicts: proxy/http2/Http2Stream.cc proxy/http2/Http2Stream.h --- proxy/http2/Http2Stream.cc | 97 ++++++++++++++++++++++++---------------------- proxy/http2/Http2Stream.h | 4 +- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc index d1bbba3..91fbdb8 100644 --- a/proxy/http2/Http2Stream.cc +++ b/proxy/http2/Http2Stream.cc @@ -309,7 +309,10 @@ Http2Stream::do_io_write(Continuation *c, int64_t nbytes, IOBufferReader *abuffe write_vio.vc_server = this; write_vio.op = VIO::WRITE; response_reader = abuffer; - return update_write_request(abuffer, nbytes, false) ? &write_vio : nullptr; + + update_write_request(abuffer, nbytes, false); + + return &write_vio; } // Initiated from SM @@ -518,12 +521,11 @@ Http2Stream::restart_sending() this->send_response_body(true); } -bool +void Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool call_update) { - bool retval = true; if (!this->is_client_state_writeable() || closed || parent == nullptr || write_vio.mutex == nullptr) { - return retval; + return; } if (this->get_thread() != this_ethread()) { SCOPED_MUTEX_LOCK(stream_lock, this->mutex, this_ethread()); @@ -531,7 +533,7 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, // Send to the right thread cross_thread_event = this->get_thread()->schedule_imm(this, VC_EVENT_WRITE_READY, nullptr); } - return retval; + return; } ink_release_assert(this->get_thread() == this_ethread()); Http2ClientSession *parent = static_cast<Http2ClientSession *>(this->get_parent()); @@ -565,54 +567,55 @@ Http2Stream::update_write_request(IOBufferReader *buf_reader, int64_t write_len, ", reader.read_avail=%" PRId64, write_vio.nbytes, write_vio.ndone, write_vio.get_writer()->write_avail(), bytes_avail); - if (bytes_avail > 0 || is_done) { - // Process the new data - if (!this->response_header_done) { - // Still parsing the response_header - int bytes_used = 0; - int state = this->response_header.parse_resp(&http_parser, this->response_reader, &bytes_used, false); - // HTTPHdr::parse_resp() consumed the response_reader in above - write_vio.ndone += this->response_header.length_get(); - - switch (state) { - case PARSE_RESULT_DONE: { - this->response_header_done = true; - - // Send the response header back - parent->connection_state.send_headers_frame(this); - - // See if the response is chunked. Set up the dechunking logic if it is - // Make sure to check if the chunk is complete and signal appropriately - this->response_initialize_data_handling(is_done); - - // If there is additional data, send it along in a data frame. Or if this was header only - // make sure to send the end of stream - if (this->response_is_data_available() || is_done) { - if ((write_vio.ntodo() + this->response_header.length_get()) == bytes_avail || is_done) { - this->mark_body_done(); - } + if (bytes_avail <= 0 && !is_done) { + return; + } + + // Process the new data + if (!this->response_header_done) { + // Still parsing the response_header + int bytes_used = 0; + int state = this->response_header.parse_resp(&http_parser, this->response_reader, &bytes_used, false); + // HTTPHdr::parse_resp() consumed the response_reader in above + write_vio.ndone += this->response_header.length_get(); + + switch (state) { + case PARSE_RESULT_DONE: { + this->response_header_done = true; - this->send_response_body(call_update); + // Send the response header back + parent->connection_state.send_headers_frame(this); + + // See if the response is chunked. Set up the dechunking logic if it is + // Make sure to check if the chunk is complete and signal appropriately + this->response_initialize_data_handling(is_done); + + // If there is additional data, send it along in a data frame. Or if this was header only + // make sure to send the end of stream + if (this->response_is_data_available() || is_done) { + if ((write_vio.ntodo() + this->response_header.length_get()) == bytes_avail || is_done) { + this->mark_body_done(); } - break; - } - case PARSE_RESULT_CONT: - // Let it ride for next time - break; - default: - break; - } - } else { - if (write_vio.ntodo() == bytes_avail || is_done) { - this->mark_body_done(); - retval = false; - } - this->send_response_body(call_update); + this->send_response_body(call_update); + } + break; + } + case PARSE_RESULT_CONT: + // Let it ride for next time + break; + default: + break; } + } else { + if (write_vio.ntodo() == bytes_avail || is_done) { + this->mark_body_done(); + } + + this->send_response_body(call_update); } - return retval; + return; } void diff --git a/proxy/http2/Http2Stream.h b/proxy/http2/Http2Stream.h index 87f7c34..3bc1dab 100644 --- a/proxy/http2/Http2Stream.h +++ b/proxy/http2/Http2Stream.h @@ -177,13 +177,12 @@ public: void terminate_if_possible(); void do_io_shutdown(ShutdownHowTo_t) {} void update_read_request(int64_t read_len, bool send_update); - bool update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool send_update); + void update_write_request(IOBufferReader *buf_reader, int64_t write_len, bool send_update); void signal_write_event(bool call_update); void reenable(VIO *vio); virtual void transaction_done(); void restart_sending(); - void send_response_body(bool call_update); void push_promise(URL &url, const MIMEField *accept_encoding); // Stream level window size @@ -261,6 +260,7 @@ private: void response_process_data(bool &is_done); bool response_is_data_available() const; Event *send_tracked_event(Event *event, int send_event, VIO *vio); + void send_response_body(bool call_update); HTTPParser http_parser; ink_hrtime _start_time; -- To stop receiving notification emails like this one, please contact zw...@apache.org.