stream: Return false from push() more properly
There are cases where a push() call would return true, even though the thing being pushed was in fact way way larger than the high water mark, simply because the 'needReadable' was already set, and would not get unset until nextTick. In some cases, this could lead to an infinite loop of pushing data into the buffer, never getting to the 'readable' event which would unset the needReadable flag. Fix by splitting up the emitReadable function, so that it always sets the flag on this tick, even if it defers until nextTick to actually emit the event. Also, if we're not ending or already in the process of reading, it now calls read(0) if we're below the high water mark. Thus, the highWaterMark value is the intended amount to buffer up to, and it is smarter about hitting the target.
parent
3b2e9d26
Please register or sign in to comment