From 06e321d0f9692af1b6c6909cdfc49fd1b197129c Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 5 Oct 2012 07:45:03 -0700 Subject: 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. --- lib/_stream_writable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3