Skip to content

Commit 0f6a952

Browse files
addaleaxcodebytere
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 0c73221 commit 0f6a952

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
@@ -310,10 +310,12 @@ function TLSSocket(socket, opts) {
310310

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

318320
// Just a documented property to make secure sockets
319321
// distinguishable from regular ones.

0 commit comments

Comments
 (0)