summaryrefslogtreecommitdiff
path: root/src/node_http2.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-02-22 14:37:58 +0100
committerAnna Henningsen <anna@addaleax.net>2018-03-15 12:53:06 +0100
commitf734b3eb04c0d355ef7ab893ed5869b867d35642 (patch)
tree88950ea4877e1394e491bcfc4b9f8d217f27a0b6 /src/node_http2.cc
parentc412150582de524beacd180646ec5f18c518a922 (diff)
downloadandroid-node-v8-f734b3eb04c0d355ef7ab893ed5869b867d35642.tar.gz
android-node-v8-f734b3eb04c0d355ef7ab893ed5869b867d35642.tar.bz2
android-node-v8-f734b3eb04c0d355ef7ab893ed5869b867d35642.zip
src: give StreamBases the capability to ask for data
Add a `OnStreamWantsWrite()` event that allows streams to ask for more input data if they want some. PR-URL: https://github.com/nodejs/node/pull/18936 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_http2.cc')
-rw-r--r--src/node_http2.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/node_http2.cc b/src/node_http2.cc
index 939e0011bd..8dd222a692 100644
--- a/src/node_http2.cc
+++ b/src/node_http2.cc
@@ -2219,6 +2219,11 @@ ssize_t Http2Stream::Provider::Stream::OnRead(nghttp2_session* handle,
if (amount == 0 && stream->IsWritable()) {
CHECK(stream->queue_.empty());
DEBUG_HTTP2SESSION2(session, "deferring stream %d", id);
+ stream->EmitWantsWrite(length);
+ if (stream->available_outbound_length_ > 0 || !stream->IsWritable()) {
+ // EmitWantsWrite() did something interesting synchronously, restart:
+ return OnRead(handle, id, buf, length, flags, source, user_data);
+ }
return NGHTTP2_ERR_DEFERRED;
}