summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-05 22:09:27 -0800
committerisaacs <i@izs.me>2013-03-06 11:44:30 -0800
commit8c44869f1dc2cdc7337d5a2a4f64e10494b0fb2f (patch)
tree0ed0b4acee7aaf964c6c6f2146bd365bed991451 /lib
parente0cec37d50b2fea9b6d8c79d52241afbf3d83c4e (diff)
downloadandroid-node-v8-8c44869f1dc2cdc7337d5a2a4f64e10494b0fb2f.tar.gz
android-node-v8-8c44869f1dc2cdc7337d5a2a4f64e10494b0fb2f.tar.bz2
android-node-v8-8c44869f1dc2cdc7337d5a2a4f64e10494b0fb2f.zip
stream: Increase highWaterMark on large reads
If the consumer of a Readable is asking for N bytes, and N > hwm, then clearly we have set the hwm to low, and ought to increase it. Fix #4931
Diffstat (limited to 'lib')
-rw-r--r--lib/_stream_readable.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 17d186f9f3..1131b24a2e 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -181,6 +181,11 @@ function howMuchToRead(n, state) {
if (n <= 0)
return 0;
+ // If we're asking for more than the target buffer level,
+ // then raise the water mark.
+ if (n > state.highWaterMark)
+ state.highWaterMark = n;
+
// don't have that much. return null, unless we've ended.
if (n > state.length) {
if (!state.ended) {