Repository navigation
Commit de754b0
committed
fix(broker): re-arm the idle timer when an orphaned stream finishes
Addresses the third review finding on #680.
A client can disconnect while its streaming request is still awaiting a
response. The close handler clears ownership and arms the timer, but the
response then assigns the already-closed socket to activeStreamSocket. The
pending timer therefore finds the broker "busy", declines to re-arm, and when
turn/completed later clears that stale ownership nothing schedules again -- the
empty broker stays resident forever, which is the leak this PR exists to close.
Two changes, closing two variants:
- armIdleTimer() is now also called when ownership is released: in
routeNotification on turn/completed, and on both the success and error paths
of a request. The socket that owned the stream may already be gone, so no
further close handler will fire to schedule it.
- isIdle() no longer counts ownership held by a destroyed socket as busy. That
covers the second variant, where turn/completed never arrives at all and the
stale ownership would otherwise pin the broker open indefinitely. A destroyed
socket has nobody listening, so there is no stream left to protect.
Test: a client starts a thread, fires turn/start, and destroys the socket
without reading the response. Verified non-vacuous against 09338b1, where it
fails with "broker stayed resident after the client abandoned a stream".1 parent 09338b1 commit de754b0
2 files changed
Lines changed: 70 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
117 | | - | |
| 125 | + | |
118 | 126 | | |
119 | 127 | | |
120 | 128 | | |
| |||
170 | 178 | | |
171 | 179 | | |
172 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
173 | 184 | | |
174 | 185 | | |
175 | 186 | | |
| |||
288 | 299 | | |
289 | 300 | | |
290 | 301 | | |
| 302 | + | |
291 | 303 | | |
292 | 304 | | |
293 | 305 | | |
| |||
299 | 311 | | |
300 | 312 | | |
301 | 313 | | |
| 314 | + | |
302 | 315 | | |
303 | 316 | | |
304 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
0 commit comments