Commit a0f8da7
net.http: free TLS resources for force-closed idle connections
The previous fix skipped conn.shutdown() entirely for an idle TLS connection
that close_idle force-closed on Windows, to avoid closing the socket a second
time. But SSLConn.shutdown() does two jobs: it frees the mbedtls TLS resources
(SSL context, config, certs, RNG state, ALPN allocation) AND closes the socket.
Skipping it leaked all of those for every force-closed idle connection at
server shutdown.
Split the two concerns instead of bypassing cleanup: when close_idle already
owns the socket close (was_force_closed), relinquish socket ownership
(conn.owns_socket = false) and still call conn.shutdown(). shutdown() then frees
the TLS resources but skips net.close, so the fd is still closed exactly once
(by close_idle) and nothing leaks. On non-Windows was_force_closed is always
false and the worker remains the sole closer, unchanged. Found by Codex on
#27542.
Co-Authored-By: WOZCODE <contact@withwoz.com>1 parent 31405a6 commit a0f8da7
2 files changed
Lines changed: 23 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
77 | | - | |
78 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
168 | 171 | | |
| 172 | + | |
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
| |||
0 commit comments