nghttpx: Http2Upstream: Try to read data from backend if buffer is empty

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-17 17:37:32 +09:00
parent 1cb6d5cb6d
commit f92110c54c
1 changed files with 10 additions and 0 deletions

View File

@ -963,6 +963,16 @@ ssize_t downstream_data_read_callback(nghttp2_session *session,
auto body = downstream->get_response_buf();
assert(body);
auto dconn = downstream->get_downstream_connection();
if (body->rleft() == 0 && dconn) {
// 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 NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
auto nread = body->remove(buf, length);
auto body_empty = body->rleft() == 0;