diff options
author | Ouyang Yadong <oyydoibh@gmail.com> | 2018-10-07 21:18:15 +0800 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-10-12 05:17:22 +0200 |
commit | e4dea40ce779ae03a77c194074e5aa06a8a28a78 (patch) | |
tree | 8d47b65806471bd26ef70db3fec35ceb6a44a9c1 /lib | |
parent | 7cc0b3cad556e6a8306861bbf478f21a50f9b24c (diff) | |
download | android-node-v8-e4dea40ce779ae03a77c194074e5aa06a8a28a78.tar.gz android-node-v8-e4dea40ce779ae03a77c194074e5aa06a8a28a78.tar.bz2 android-node-v8-e4dea40ce779ae03a77c194074e5aa06a8a28a78.zip |
tls: make StreamWrap work correctly in "drain" callback
When an instance of StreamWrap is shutting down and a "drain" event
is emitted, the instance will abort as its
`this[kCurrentShutdownRequest]` is already set. The following test
will fail before this commit.
PR-URL: https://github.com/nodejs/node/pull/23294
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/wrap_js_stream.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/wrap_js_stream.js index b51e008705..e6de433676 100644 --- a/lib/internal/wrap_js_stream.js +++ b/lib/internal/wrap_js_stream.js @@ -100,9 +100,6 @@ class JSStreamWrap extends Socket { } doShutdown(req) { - assert.strictEqual(this[kCurrentShutdownRequest], null); - this[kCurrentShutdownRequest] = req; - // TODO(addaleax): It might be nice if we could get into a state where // DoShutdown() is not called on streams while a write is still pending. // @@ -113,8 +110,10 @@ class JSStreamWrap extends Socket { // so for now that is supported here. if (this[kCurrentWriteRequest] !== null) - return this.on('drain', () => this.doShutdown(req)); + return this.once('drain', () => this.doShutdown(req)); assert.strictEqual(this[kCurrentWriteRequest], null); + assert.strictEqual(this[kCurrentShutdownRequest], null); + this[kCurrentShutdownRequest] = req; const handle = this._handle; |