Commit f0aee49
committed
fix(websocket): close proxy socket on tunnel shutdown so wss-via-proxy upgrade resources free
WebSocketProxyTunnel.shutdown() only sent TLS close_notify and never
closed the underlying socket, so the upgrade client's handleClose never
fired, proxy.deinit never ran, and the tunnel + per-connection SSL_CTX +
upgrade client all leaked (~2.5MB per wss-via-http-proxy connection).
shutdown() now takes the socket out (so a re-entrant call via
handleClose -> clearData -> proxy.deinit -> tunnel.shutdown finds .none
and is a no-op) and closes it. The synchronous re-entry is refcount-safe
without an extra guard: tunnel is at 2 (proxy + WebSocketClient) before
cleanup; proxy.deinit derefs to 1; the WebSocketClient cleanup's own
deref takes it to 0.
Test runs 200 connect/close cycles with servers in a separate process
and asserts client RSS growth < 1.5MB/iter (pre-fix ~2.5MB/iter,
post-fix ~1.0MB/iter).1 parent 0ff0065 commit f0aee49
File tree
3 files changed
+183
-0
lines changed- src/http/websocket_client
- test/js/web/websocket
3 files changed
+183
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| |||
339 | 346 | | |
340 | 347 | | |
341 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
342 | 356 | | |
343 | 357 | | |
344 | 358 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| 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 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments