Commit 5a6d6ccb authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Read from backend eagerly in all upstreams

parent 426fbda7
......@@ -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) {
......
......@@ -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) {
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment