nghttpx: Read from backend eagerly in all upstreams

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-21 01:41:17 +09:00
parent 426fbda799
commit 5a6d6ccbd4
3 changed files with 20 additions and 1 deletions

View File

@ -1006,7 +1006,8 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
auto dconn = downstream->get_downstream_connection();
if (body->rleft() == 0 && dconn) {
if (body->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
// Try to read more if buffer is empty. This will help small
// buffer and make priority handling a bit better.
if (upstream->downstream_read(dconn) != 0) {

View File

@ -391,7 +391,14 @@ int HttpsUpstream::on_write() {
if (!downstream) {
return 0;
}
auto dconn = downstream->get_downstream_connection();
auto wb = handler_->get_wb();
if (wb->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
if (downstream_read(dconn) != 0) {
return -1;
}
}
struct iovec iov[2];
auto iovcnt = wb->wiovec(iov);
if (iovcnt == 0) {

View File

@ -704,6 +704,17 @@ ssize_t spdy_data_read_callback(spdylay_session *session, int32_t stream_id,
auto body = downstream->get_response_buf();
assert(body);
auto dconn = downstream->get_downstream_connection();
if (body->rleft() == 0 && dconn &&
downstream->get_response_state() != Downstream::MSG_COMPLETE) {
// Try to read more if buffer is empty. This will help small
// buffer and make priority handling a bit better.
if (upstream->downstream_read(dconn) != 0) {
return SPDYLAY_ERR_CALLBACK_FAILURE;
}
}
auto nread = body->remove(buf, length);
auto body_empty = body->rleft() == 0;