Commit bf25994
tls: fix leak of WriteWrap+TLSWrap combination
Writing data to TLSWrap instance during handshake will result in it
being queued in `write_item_queue_`. This queue won't get cleared up
until the end of the handshake.
Technically, it gets cleared on `~TLSWrap` invocation, however this
won't ever happen because every `WriteWrap` holds a reference to the
`TLSWrap` through JS object, meaning that they are doomed to be alive
for eternity.
To breach this dreadful contract a knight shall embark from the
`close` function to kill the dragon of memory leak with his magic
spear of `destroySSL`.
`destroySSL` cleans up `write_item_queue_` and frees `SSL` structure,
both are good for memory usage.
PR-URL: #9586
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>1 parent d1d207b commit bf25994Copy full SHA for bf25994
File tree
Expand file treeCollapse file tree
2 files changed
+46
-3
lines changedOpen diff view settings
Filter options
- lib
- test/parallel
Expand file treeCollapse file tree
2 files changed
+46
-3
lines changedOpen diff view settings
Collapse file
+20-3Lines changed: 20 additions & 3 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
317 | 317 | |
318 | 318 | |
319 | 319 | |
320 | | - |
| 320 | + |
| 321 | + |
| 322 | + |
321 | 323 | |
| 324 | + |
| 325 | + |
| 326 | + |
| 327 | + |
| 328 | + |
| 329 | + |
| 330 | + |
| 331 | + |
| 332 | + |
| 333 | + |
| 334 | + |
| 335 | + |
| 336 | + |
| 337 | + |
| 338 | + |
322 | 339 | |
323 | 340 | |
324 | | - |
| 341 | + |
325 | 342 | |
326 | 343 | |
327 | | - |
| 344 | + |
328 | 345 | |
329 | 346 | |
330 | 347 | |
|
Collapse file
test/parallel/test-tls-writewrap-leak.js
Copy file name to clipboard+26Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
0 commit comments