From 1cde519287b925a0be4485f3766fb5ceb60f94cd Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 2 Sep 2019 01:36:03 +0200 Subject: http2: send out pending data earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there’s a lot of data waiting on a given stream, send it out early, if possible. This helps trigger the backpressure mechanism introduced in 8a4a1931b8b98 at a better time. PR-URL: https://github.com/nodejs/node/pull/29398 Reviewed-By: David Carlier Reviewed-By: James M Snell --- src/node_http2.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index a5b834dc2c..d09676d858 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1188,7 +1188,10 @@ int Http2Session::OnDataChunkReceived(nghttp2_session* handle, stream->inbound_consumed_data_while_paused_ += avail; // If we have a gathered a lot of data for output, try sending it now. - if (session->outgoing_length_ > 4096) session->SendPendingData(); + if (session->outgoing_length_ > 4096 || + stream->available_outbound_length_ > 4096) { + session->SendPendingData(); + } } while (len != 0); // If we are currently waiting for a write operation to finish, we should -- cgit v1.2.3