summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-04-03 00:37:49 +0200
committerJames M Snell <jasnell@gmail.com>2016-04-11 22:50:45 -0700
commit819b2d36bcffdb9f33e0e4497ac818d64fe5711d (patch)
treeaea034c641263a520ba467f0ec8e0db2c176dab2 /lib
parent5dafb435d8946805cbb25bccb1bfac31139915d1 (diff)
downloadandroid-node-v8-819b2d36bcffdb9f33e0e4497ac818d64fe5711d.tar.gz
android-node-v8-819b2d36bcffdb9f33e0e4497ac818d64fe5711d.tar.bz2
android-node-v8-819b2d36bcffdb9f33e0e4497ac818d64fe5711d.zip
stream: Fix readableState.awaitDrain mechanism
In 68990948fe4 (https://github.com/nodejs/node/pull/2325), the conditions for increasing `readableState.awaitDrain` when writing to a piping destination returns false were changed so that they could not actually be met, effectively leaving `readableState.awaitDrain` with a constant value of 0. This patch changes the conditions to testing whether the stream for which `.write()` returned false is still a piping destination, which was likely the intention of the original patch. Fixes: https://github.com/nodejs/node/issues/5820 Fixes: https://github.com/nodejs/node/issues/5257 PR-URL: https://github.com/nodejs/node/pull/6023 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/_stream_readable.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 338bf2a753..275691cbb2 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -538,9 +538,9 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
// If the user unpiped during `dest.write()`, it is possible
// to get stuck in a permanently paused state if that write
// also returned false.
- if (state.pipesCount === 1 &&
- state.pipes[0] === dest &&
- src.listenerCount('data') === 1 &&
+ // => Check whether `dest` is still a piping destination.
+ if (((state.pipesCount === 1 && state.pipes === dest) ||
+ (state.pipesCount > 1 && state.pipes.indexOf(dest) !== -1)) &&
!cleanedUp) {
debug('false write response, pause', src._readableState.awaitDrain);
src._readableState.awaitDrain++;