stream: remove usage of *State.highWaterMark

Replaced _readableState.highWaterMark with a .readableHighWaterMark
getter and _writableState.highWaterMark with a .writableHighWaterMark
getter.
The getters are non-enumerable because they break some prototype
manipulation that happen in the ecosystem.

Ref: https://github.com/nodejs/node/issues/445.

PR-URL: https://github.com/nodejs/node/pull/12860
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Calvin Metcalf authored and Matteo Collina committed 2017-11-15 14:30:39 +01:00
1 parent 9c1b18a59f
commit 157df5a47c
11 files changed
+73 -17

No files matched your search

+3 -3
View File
@@ -373,13 +373,13 @@ function connectionListener(socket) {
function updateOutgoingData(socket, state, delta) {
state.outgoingData += delta;
if (socket._paused &&
state.outgoingData < socket._writableState.highWaterMark) {
state.outgoingData < socket.writeHWM) {
return socketOnDrain(socket, state);
}
}
function socketOnDrain(socket, state) {
var needPause = state.outgoingData > socket._writableState.highWaterMark;
var needPause = state.outgoingData > socket.writeHWM;
// If we previously paused, then start reading again.
if (socket._paused && !needPause) {
@@ -569,7 +569,7 @@ function parserOnIncoming(server, socket, state, req, keepAlive) {
// pipelined requests that may never be resolved.
if (!socket._paused) {
var ws = socket._writableState;
if (ws.needDrain || state.outgoingData >= ws.highWaterMark) {
if (ws.needDrain || state.outgoingData >= socket.writableHighWaterMark) {
socket._paused = true;
// We also need to pause the parser, but don't do that until after
// the call to execute, because we may still be processing the last