tls: destroy TLS socket if StreamWrap is destroyed

Previously, there was no mechanism in place that would
have destroyed the TLS socket once the underlying socket
had been closed.

PR-URL: https://github.com/nodejs/node/pull/24290
Refs: https://github.com/nodejs/node/pull/24288
Refs: https://github.com/nodejs/node/pull/24075
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Ouyang Yadong <oyydoibh@gmail.com>
This commit is contained in:
Anna Henningsen 2018-11-10 21:11:17 +01:00
parent cbbf64e40e
commit b92d55f718
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -310,10 +310,12 @@ function TLSSocket(socket, opts) {
// Wrap plain JS Stream into StreamWrap
var wrap;
if ((socket instanceof net.Socket && socket._handle) || !socket)
if ((socket instanceof net.Socket && socket._handle) || !socket) {
wrap = socket;
else
} else {
wrap = new StreamWrap(socket);
wrap.once('close', () => this.destroy());
}
// Just a documented property to make secure sockets
// distinguishable from regular ones.