nghttpx: Remove deprecated evbuffer_setcb, send WU before buffer gets empty
This commit is contained in:
parent
0872ce27f4
commit
8f3d4fdeec
|
@ -635,18 +635,6 @@ int Downstream::get_response_state() const
|
|||
return response_state_;
|
||||
}
|
||||
|
||||
namespace {
|
||||
void body_buf_cb(evbuffer *body, size_t oldlen, size_t newlen, void *arg)
|
||||
{
|
||||
Downstream *downstream = reinterpret_cast<Downstream*>(arg);
|
||||
if(newlen == 0) {
|
||||
if(downstream->resume_read(SHRPX_NO_BUFFER) == -1) {
|
||||
DLOG(WARNING, downstream) << "Sending WINDOW_UPDATE failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int Downstream::init_response_body_buf()
|
||||
{
|
||||
if(!response_body_buf_) {
|
||||
|
@ -654,7 +642,6 @@ int Downstream::init_response_body_buf()
|
|||
if(response_body_buf_ == nullptr) {
|
||||
DIE();
|
||||
}
|
||||
evbuffer_setcb(response_body_buf_, body_buf_cb, this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ int Http2DownstreamConnection::init_request_body_buf()
|
|||
if(request_body_buf_ == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
evbuffer_setcb(request_body_buf_, nullptr, this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -212,6 +211,14 @@ ssize_t http2_data_read_callback(nghttp2_session *session,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// Send WINDOW_UPDATE before buffer is empty to avoid delay
|
||||
// because of RTT.
|
||||
if(!downstream->get_output_buffer_full() &&
|
||||
downstream->get_upstream()->resume_read(SHRPX_NO_BUFFER,
|
||||
downstream) == -1) {
|
||||
// In this case, downstream may be deleted.
|
||||
return NGHTTP2_ERR_DEFERRED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -902,6 +902,13 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
|
|||
(downstream->get_response_rst_stream_error_code()));
|
||||
}
|
||||
}
|
||||
// Send WINDOW_UPDATE before buffer is empty to avoid delay because
|
||||
// of RTT.
|
||||
if(*eof != 1 &&
|
||||
evbuffer_get_length(body) < SHRPX_HTTP2_UPSTREAM_OUTPUT_UPPER_THRES &&
|
||||
downstream->resume_read(SHRPX_NO_BUFFER) != 0) {
|
||||
DLOG(WARNING, downstream) << "Sending WINDOW_UPDATE failed";
|
||||
}
|
||||
if(nread == 0 && *eof != 1) {
|
||||
return NGHTTP2_ERR_DEFERRED;
|
||||
}
|
||||
|
|
|
@ -457,6 +457,10 @@ int htp_msg_completecb(http_parser *htp)
|
|||
{
|
||||
auto downstream = reinterpret_cast<Downstream*>(htp->data);
|
||||
downstream->set_response_state(Downstream::MSG_COMPLETE);
|
||||
// Block reading another response message from (broken?)
|
||||
// server. This callback is not called if the connection is
|
||||
// tunneled.
|
||||
downstream->pause_read(SHRPX_MSG_BLOCK);
|
||||
return downstream->get_upstream()->on_downstream_body_complete(downstream);
|
||||
}
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in New Issue