diff options
author | isaacs <i@izs.me> | 2012-10-05 07:45:03 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-12-13 17:00:25 -0800 |
commit | 06e321d0f9692af1b6c6909cdfc49fd1b197129c (patch) | |
tree | 01fc4d803338993b721a2ad0b6edad8f80f7a70c /lib | |
parent | 02f017d24f8cd93939bb4bd178b878d15cc5a08c (diff) | |
download | android-node-v8-06e321d0f9692af1b6c6909cdfc49fd1b197129c.tar.gz android-node-v8-06e321d0f9692af1b6c6909cdfc49fd1b197129c.tar.bz2 android-node-v8-06e321d0f9692af1b6c6909cdfc49fd1b197129c.zip |
streams2: Correct drain/return logic
It was testing the length *before* adding the current chunk, which
is the opposite of correct.
Also, the return value was flipped.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_stream_writable.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 020d7abcc0..90aa285865 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -71,13 +71,13 @@ Writable.prototype.write = function(chunk, encoding) { if (typeof chunk === 'string') chunk = new Buffer(chunk, encoding); - var ret = state.length >= state.highWaterMark; - if (ret === false) - state.needDrain = true; - var l = chunk.length; state.length += l; + var ret = state.length < state.highWaterMark; + if (ret === false) + state.needDrain = true; + if (state.writing) { state.buffer.push(chunk); return ret; |