diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-28 20:46:39 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-03-31 14:09:35 +0200 |
commit | 20c3ac255619166485fd6f2a7dda09e9e842b7b6 (patch) | |
tree | 45a4d62c01c589ebdc0154c5c612ef9c7d02ca48 /lib/_stream_readable.js | |
parent | 86a29356f4ff2fb872d763fffddc53e89283aa1a (diff) | |
download | android-node-v8-20c3ac255619166485fd6f2a7dda09e9e842b7b6.tar.gz android-node-v8-20c3ac255619166485fd6f2a7dda09e9e842b7b6.tar.bz2 android-node-v8-20c3ac255619166485fd6f2a7dda09e9e842b7b6.zip |
stream: do not unconditionally call `_read()` on `resume()`
`readable.resume()` calls `.read(0)`, which in turn previously set
`needReadable = true`, and so a subsequent `.read()` call would
call `_read()` even though enough data was already available.
This can lead to elevated memory usage, because calling `_read()`
when enough data is in the readable buffer means that backpressure
is not being honoured.
Fixes: https://github.com/nodejs/node/issues/26957
PR-URL: https://github.com/nodejs/node/pull/26965
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r-- | lib/_stream_readable.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 3e46a604e5..cbbfd0ba59 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -475,7 +475,7 @@ Readable.prototype.read = function(n) { ret = null; if (ret === null) { - state.needReadable = true; + state.needReadable = state.length <= state.highWaterMark; n = 0; } else { state.length -= n; |