nghttpx: Fix freeze in large transfer

This commit is contained in:
Tatsuhiro Tsujikawa 2015-10-03 19:00:16 +09:00
parent 9fa5010eac
commit ccbaaa1e14
1 changed files with 19 additions and 8 deletions

View File

@ -679,19 +679,18 @@ int send_data_callback(nghttp2_session *session, nghttp2_frame *frame,
// Http2Upstream::remove_downstream().
upstream->set_pending_data_downstream(downstream, length - nwrite);
}
if (wb->rleft() == 0) {
downstream->disable_upstream_wtimer();
} else {
downstream->reset_upstream_wtimer();
}
if (length > 0 && downstream->resume_read(SHRPX_NO_BUFFER, length) != 0) {
if (nwrite > 0 && downstream->resume_read(SHRPX_NO_BUFFER, nwrite) != 0) {
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
if (length > 0) {
downstream->add_response_sent_bodylen(length);
if (nwrite > 0) {
downstream->add_response_sent_bodylen(nwrite);
}
return nwrite < length ? NGHTTP2_ERR_PAUSE : 0;
@ -938,16 +937,28 @@ int Http2Upstream::on_write() {
data_pending_ = nullptr;
} else {
auto n = std::min(wb_.wleft(), data_pendinglen_);
auto nwrite = std::min(wb_.wleft(), data_pendinglen_);
DefaultMemchunks *body;
if (pending_data_downstream_) {
body = pending_data_downstream_->get_response_buf();
} else {
body = &pending_response_buf_;
}
body->remove(wb_.last, n);
wb_.write(n);
data_pendinglen_ -= n;
body->remove(wb_.last, nwrite);
wb_.write(nwrite);
data_pendinglen_ -= nwrite;
if (pending_data_downstream_) {
if (nwrite > 0 &&
pending_data_downstream_->resume_read(SHRPX_NO_BUFFER, nwrite) !=
0) {
return -1;
}
if (nwrite > 0) {
pending_data_downstream_->add_response_sent_bodylen(nwrite);
}
}
if (data_pendinglen_ > 0) {
return 0;