From a65296db2c544df91e0f6c8cbc8ff79691f870fe Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 13 Jul 2020 20:05:43 -0700 Subject: [PATCH] quic: remove stream pending code Removing no longer needed code PR-URL: https://github.com/nodejs/node/pull/34351 Reviewed-By: Robert Nagy Reviewed-By: Anna Henningsen --- lib/internal/quic/core.js | 43 +----------------------- test/parallel/test-quic-client-server.js | 1 - 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/lib/internal/quic/core.js b/lib/internal/quic/core.js index a8d35c47a8633e..4fc7ca721a0e3d 100644 --- a/lib/internal/quic/core.js +++ b/lib/internal/quic/core.js @@ -1666,7 +1666,6 @@ class QuicSession extends EventEmitter { silentClose: false, statelessReset: false, stats: undefined, - pendingStreams: new Set(), streams: new Map(), verifyErrorReason: undefined, verifyErrorCode: undefined, @@ -1969,12 +1968,6 @@ class QuicSession extends EventEmitter { return; state.destroyed = true; - // Destroy any pending streams immediately. These - // are streams that have been created but have not - // yet been assigned an internal handle. - for (const stream of state.pendingStreams) - stream.destroy(error); - // Destroy any remaining streams immediately. for (const stream of state.streams.values()) stream.destroy(error); @@ -2534,7 +2527,7 @@ function streamOnResume() { } function streamOnPause() { - if (!this.destroyed /* && !this.pending */) + if (!this.destroyed) this[kHandle].readStop(); } @@ -2658,9 +2651,6 @@ class QuicStream extends Duplex { if (this.destroyed || state.closed) return; - if (this.pending) - return this.once('ready', () => this[kClose](family, code)); - state.closed = true; state.aborted = this.readable || this.writable; @@ -2712,11 +2702,6 @@ class QuicStream extends Duplex { // TODO(@jasnell): Implement this later } - get pending() { - // The id is set in the kSetHandle function - return this[kInternalState].id === undefined; - } - get aborted() { return this[kInternalState].aborted; } @@ -2741,16 +2726,6 @@ class QuicStream extends Duplex { if (this.destroyed) return; // TODO(addaleax): Can this happen? - // The stream should be corked while still pending - // but just in case uncork - // was called early, defer the actual write until the - // ready event is emitted. - if (this.pending) { - return this.once('ready', () => { - this[kWriteGeneric](writev, data, encoding, cb); - }); - } - this[kUpdateTimer](); const req = (writev) ? writevGeneric(this, data, cb) : @@ -2774,13 +2749,6 @@ class QuicStream extends Duplex { // coming so that a fin stream packet can be // sent. _final(cb) { - // The QuicStream should be corked while pending - // so this shouldn't be called, but just in case - // the stream was prematurely uncorked, defer the - // operation until the ready event is emitted. - if (this.pending) - return this.once('ready', () => this._final(cb)); - const handle = this[kHandle]; if (handle === undefined) { cb(); @@ -2796,9 +2764,6 @@ class QuicStream extends Duplex { } _read(nread) { - if (this.pending) - return this.once('ready', () => this._read(nread)); - if (this.destroyed) { // TODO(addaleax): Can this happen? this.push(null); return; @@ -2848,12 +2813,6 @@ class QuicStream extends Duplex { else if (typeof fd !== 'number') throw new ERR_INVALID_ARG_TYPE('fd', ['number', 'FileHandle'], fd); - if (this.pending) { - return this.once('ready', () => { - this.sendFD(fd, { offset, length }, ownsFd); - }); - } - this[kUpdateTimer](); this.ownsFd = ownsFd; diff --git a/test/parallel/test-quic-client-server.js b/test/parallel/test-quic-client-server.js index d9b477b7eecb94..23295ed2334bbb 100644 --- a/test/parallel/test-quic-client-server.js +++ b/test/parallel/test-quic-client-server.js @@ -170,7 +170,6 @@ client.on('close', common.mustCall(onSocketClose.bind(client))); assert(!stream.unidirectional); assert(stream.clientInitiated); assert(!stream.serverInitiated); - assert(!stream.pending); const file = fs.createReadStream(__filename); let data = '';