diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-08-06 13:41:12 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-11-05 23:26:26 +0100 |
commit | de119131bc87cf4168c949ecbbf1c1504f96a499 (patch) | |
tree | 0c003bef5e94d8ab84bafc3862db34dc988f82d6 /lib | |
parent | 074730081db3269fc3559598c0698a9f6b7b20c2 (diff) | |
download | android-node-v8-de119131bc87cf4168c949ecbbf1c1504f96a499.tar.gz android-node-v8-de119131bc87cf4168c949ecbbf1c1504f96a499.tar.bz2 android-node-v8-de119131bc87cf4168c949ecbbf1c1504f96a499.zip |
stream: add writableCorked property
PR-URL: https://github.com/nodejs/node/pull/29012
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_http_outgoing.js | 11 | ||||
-rw-r--r-- | lib/_stream_writable.js | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 32a51d120b..5345f2d979 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -56,8 +56,6 @@ const { validateString } = require('internal/validators'); const HIGH_WATER_MARK = getDefaultHighWaterMark(); const { CRLF, debug } = common; -const kIsCorked = Symbol('isCorked'); - const RE_CONN_CLOSE = /(?:^|\W)close(?:$|\W)/i; const RE_TE_CHUNKED = common.chunkExpression; @@ -101,7 +99,6 @@ function OutgoingMessage() { this.finished = false; this._headerSent = false; - this[kIsCorked] = false; this.socket = null; this._header = null; @@ -628,10 +625,9 @@ function write_(msg, chunk, encoding, callback, fromEnd) { ['string', 'Buffer'], chunk); } - if (!fromEnd && msg.socket && !msg[kIsCorked]) { + if (!fromEnd && msg.socket && !msg.socket.writableCorked) { msg.socket.cork(); - msg[kIsCorked] = true; - process.nextTick(connectionCorkNT, msg, msg.socket); + process.nextTick(connectionCorkNT, msg.socket); } var len, ret; @@ -660,8 +656,7 @@ function writeAfterEndNT(msg, err, callback) { } -function connectionCorkNT(msg, conn) { - msg[kIsCorked] = false; +function connectionCorkNT(conn) { conn.uncork(); } diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 9b75b672cb..9b4036e476 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -385,6 +385,16 @@ Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { } }); +Object.defineProperty(Writable.prototype, 'writableCorked', { + // Making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function() { + return this._writableState ? this._writableState.corked : 0; + } +}); + // If we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. |