GeezerVison is showing github.com — src: use consistent names for JSStream · nodejs/node@bc66356
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 'use strict'; | 2 | 2 |
| 3 | | -module.exports = require('internal/wrap_js_stream'); | | 3 | +module.exports = require('internal/js_stream_socket'); |
Collapse file Copy file name to clipboardExpand all lines: lib/_tls_wrap.js +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,7 +29,7 @@ const net = require('net'); | 29 | 29 | const tls = require('tls'); | 30 | 30 | const util = require('util'); | 31 | 31 | const common = require('_tls_common'); | 32 | | -const { StreamWrap } = require('_stream_wrap'); | | 32 | +const JSStreamSocket = require('internal/js_stream_socket'); | 33 | 33 | const { Buffer } = require('buffer'); | 34 | 34 | const debug = util.debuglog('tls'); | 35 | 35 | const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); | @@ -308,12 +308,14 @@ function TLSSocket(socket, opts) { | 308 | 308 | this.authorizationError = null; | 309 | 309 | this[kRes] = null; | 310 | 310 |
| 311 | | - // Wrap plain JS Stream into StreamWrap | 312 | 311 | var wrap; | 313 | 312 | if ((socket instanceof net.Socket && socket._handle) || !socket) { | 314 | 313 | wrap = socket; | 315 | 314 | } else { | 316 | | - wrap = new StreamWrap(socket); | | 315 | + // TLS expects to interact from C++ with a net.Socket that has a C++ stream | | 316 | + // handle, but a JS stream doesn't have one. Wrap it up to make it look like | | 317 | + // a socket. | | 318 | + wrap = new JSStreamSocket(socket); | 317 | 319 | wrap.once('close', () => this.destroy()); | 318 | 320 | } | 319 | 321 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ const util = require('util'); | 22 | 22 |
| 23 | 23 | const { kIncomingMessage } = require('_http_common'); | 24 | 24 | const { kServerResponse } = require('_http_server'); | 25 | | -const { StreamWrap } = require('_stream_wrap'); | | 25 | +const JSStreamSocket = require('internal/js_stream_socket'); | 26 | 26 |
| 27 | 27 | const { | 28 | 28 | defaultTriggerAsyncIdScope, | @@ -935,7 +935,7 @@ class Http2Session extends EventEmitter { | 935 | 935 | super(); | 936 | 936 |
| 937 | 937 | if (!socket._handle || !socket._handle._externalStream) { | 938 | | - socket = new StreamWrap(socket); | | 938 | + socket = new JSStreamSocket(socket); | 939 | 939 | } | 940 | 940 |
| 941 | 941 | // No validation is performed on the input parameters because this | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/js_stream_socket.js +8-7Lines changed: 8 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,7 +5,7 @@ const util = require('util'); | 5 | 5 | const { Socket } = require('net'); | 6 | 6 | const { JSStream } = internalBinding('js_stream'); | 7 | 7 | const uv = internalBinding('uv'); | 8 | | -const debug = util.debuglog('stream_wrap'); | | 8 | +const debug = util.debuglog('stream_socket'); | 9 | 9 | const { owner_symbol } = require('internal/async_hooks').symbols; | 10 | 10 | const { ERR_STREAM_WRAP } = require('internal/errors').codes; | 11 | 11 |
| @@ -29,17 +29,17 @@ function onwrite(req, bufs) { return this[owner_symbol].doWrite(req, bufs); } | 29 | 29 | * can skip going through the JS layer and let TLS access the raw C++ handle | 30 | 30 | * of a net.Socket. The flipside of this is that, to maintain composability, | 31 | 31 | * we need a way to create "fake" net.Socket instances that call back into a | 32 | | - * "real" JavaScript stream. JSStreamWrap is exactly this. | | 32 | + * "real" JavaScript stream. JSStreamSocket is exactly this. | 33 | 33 | */ | 34 | | -class JSStreamWrap extends Socket { | | 34 | +class JSStreamSocket extends Socket { | 35 | 35 | constructor(stream) { | 36 | 36 | const handle = new JSStream(); | 37 | 37 | handle.close = (cb) => { | 38 | 38 | debug('close'); | 39 | 39 | this.doClose(cb); | 40 | 40 | }; | 41 | 41 | // Inside of the following functions, `this` refers to the handle | 42 | | - // and `this[owner_symbol]` refers to this JSStreamWrap instance. | | 42 | + // and `this[owner_symbol]` refers to this JSStreamSocket instance. | 43 | 43 | handle.isClosing = isClosing; | 44 | 44 | handle.onreadstart = onreadstart; | 45 | 45 | handle.onreadstop = onreadstop; | @@ -88,9 +88,10 @@ class JSStreamWrap extends Socket { | 88 | 88 | this.read(0); | 89 | 89 | } | 90 | 90 |
| 91 | | - // Legacy | | 91 | + // Allow legacy requires in the test suite to keep working: | | 92 | + // const { StreamWrap } = require('internal/js_stream_socket') | 92 | 93 | static get StreamWrap() { | 93 | | - return JSStreamWrap; | | 94 | + return JSStreamSocket; | 94 | 95 | } | 95 | 96 |
| 96 | 97 | isClosing() { | @@ -223,4 +224,4 @@ class JSStreamWrap extends Socket { | 223 | 224 | } | 224 | 225 | } | 225 | 226 |
| 226 | | -module.exports = JSStreamWrap; | | 227 | +module.exports = JSStreamSocket; |
Collapse file Copy file name to clipboardExpand all lines: node.gyp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 124 | 124 | 'lib/internal/fs/watchers.js', | 125 | 125 | 'lib/internal/http.js', | 126 | 126 | 'lib/internal/inspector_async_hook.js', | | 127 | + 'lib/internal/js_stream_socket.js', | 127 | 128 | 'lib/internal/linkedlist.js', | 128 | 129 | 'lib/internal/modules/cjs/helpers.js', | 129 | 130 | 'lib/internal/modules/cjs/loader.js', | | 186 | 187 | 'lib/internal/streams/state.js', | 187 | 188 | 'lib/internal/streams/pipeline.js', | 188 | 189 | 'lib/internal/streams/end-of-stream.js', | 189 | | - 'lib/internal/wrap_js_stream.js', | 190 | 190 | 'deps/v8/tools/splaytree.js', | 191 | 191 | 'deps/v8/tools/codemap.js', | 192 | 192 | 'deps/v8/tools/consarray.js', | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap-drain.js +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | 'use strict'; | 3 | 3 | const common = require('../common'); | 4 | 4 | const assert = require('assert'); | 5 | | -const { StreamWrap } = require('_stream_wrap'); | | 5 | +const { StreamWrap } = require('internal/js_stream_socket'); | 6 | 6 | const { Duplex } = require('stream'); | 7 | 7 | const { internalBinding } = require('internal/test/binding'); | 8 | 8 | const { ShutdownWrap } = internalBinding('stream_wrap'); | 9 | 9 |
| 10 | | -// This test makes sure that when an instance of JSStreamWrap is waiting for | | 10 | +// This test makes sure that when a wrapped stream is waiting for | 11 | 11 | // a "drain" event to `doShutdown`, the instance will work correctly when a | 12 | 12 | // "drain" event emitted. | 13 | 13 | { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap-encoding.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 | const common = require('../common'); | 3 | 4 |
| 4 | | -const StreamWrap = require('_stream_wrap'); | | 5 | +const StreamWrap = require('internal/js_stream_socket'); | 5 | 6 | const Duplex = require('stream').Duplex; | 6 | 7 |
| 7 | 8 | { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-stream-wrap.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,7 +4,7 @@ const common = require('../common'); | 4 | 4 | const assert = require('assert'); | 5 | 5 |
| 6 | 6 | const { internalBinding } = require('internal/test/binding'); | 7 | | -const StreamWrap = require('_stream_wrap'); | | 7 | +const StreamWrap = require('internal/js_stream_socket'); | 8 | 8 | const { Duplex } = require('stream'); | 9 | 9 | const { ShutdownWrap } = internalBinding('stream_wrap'); | 10 | 10 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-wrap-js-stream-destroy.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 |
| 3 | 4 | const common = require('../common'); | 4 | | -const StreamWrap = require('_stream_wrap'); | | 5 | +const StreamWrap = require('internal/js_stream_socket'); | 5 | 6 | const net = require('net'); | 6 | 7 |
| 7 | 8 | // This test ensures that when we directly call `socket.destroy()` without | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-wrap-js-stream-duplex.js +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// Flags: --expose-internals | 1 | 2 | 'use strict'; | 2 | 3 | const common = require('../common'); | 3 | 4 | const assert = require('assert'); | 4 | | -const StreamWrap = require('_stream_wrap'); | | 5 | +const StreamWrap = require('internal/js_stream_socket'); | 5 | 6 | const { PassThrough } = require('stream'); | 6 | 7 | const { Socket } = require('net'); | 7 | 8 |
| |
|