diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-03-07 14:22:36 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-10 02:46:54 +0300 |
commit | e7f58868b5ea1312f7bac4f152f4d928b64e0202 (patch) | |
tree | e06a734c0302b86fca764a34f9325b8032261d5d /lib/internal/stream_base_commons.js | |
parent | 3414bc7b25a00556af80c6ba946e28464e7e8d36 (diff) |
net: use kHandle symbol for accessing native handle
Use a common `kHandle` for all `StreamBase`-based streams.
PR-URL: https://github.com/nodejs/node/pull/26491
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/stream_base_commons.js')
-rw-r--r-- | lib/internal/stream_base_commons.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 64ea864e294..7b5798e82a3 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -27,7 +27,8 @@ const { const kMaybeDestroy = Symbol('kMaybeDestroy'); const kUpdateTimer = Symbol('kUpdateTimer'); const kAfterAsyncWrite = Symbol('kAfterAsyncWrite'); -const kSession = Symbol('session'); +const kHandle = Symbol('kHandle'); +const kSession = Symbol('kSession'); function handleWriteReq(req, data, encoding) { const { handle } = req; @@ -98,7 +99,8 @@ function createWriteWrap(handle) { return req; } -function writevGeneric(self, req, data, cb) { +function writevGeneric(self, data, cb) { + const req = createWriteWrap(self[kHandle]); var allBuffers = data.allBuffers; var chunks; var i; @@ -120,12 +122,15 @@ function writevGeneric(self, req, data, cb) { if (err === 0) req._chunks = chunks; afterWriteDispatched(self, req, err, cb); + return req; } -function writeGeneric(self, req, data, encoding, cb) { +function writeGeneric(self, data, encoding, cb) { + const req = createWriteWrap(self[kHandle]); var err = handleWriteReq(req, data, encoding); afterWriteDispatched(self, req, err, cb); + return req; } function afterWriteDispatched(self, req, err, cb) { @@ -229,6 +234,7 @@ module.exports = { kAfterAsyncWrite, kMaybeDestroy, kUpdateTimer, + kHandle, kSession, setStreamTimeout }; |