Skip to content

Commit 71a9c98

Browse files
addaleaxrvagg
authored andcommitted
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: #24290 Refs: #24288 Refs: #24075 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Ouyang Yadong <[email protected]>
1 parent 0c93b12 commit 71a9c98

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/_tls_wrap.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ function TLSSocket(socket, opts) {
308308

309309
// Wrap plain JS Stream into StreamWrap
310310
var wrap;
311-
if ((socket instanceof net.Socket && socket._handle) || !socket)
311+
if ((socket instanceof net.Socket && socket._handle) || !socket) {
312312
wrap = socket;
313-
else
313+
} else {
314314
wrap = new StreamWrap(socket);
315+
wrap.once('close', () => this.destroy());
316+
}
315317

316318
// Just a documented property to make secure sockets
317319
// distinguishable from regular ones.

0 commit comments

Comments
 (0)