Repository navigation
Commit cfc4188
committed
fix(broker): release stale socket ownership instead of tolerating it
Addresses the fourth review finding on #680, which is a defect the previous
commit introduced.
de754b0 taught isIdle() to ignore ownership held by a destroyed socket, but the
busy guard and the notification target still tested those fields for non-null.
The three checks could therefore disagree: after an abandoned streaming request
assigned its destroyed socket to activeStreamSocket, the broker reported itself
idle while answering every new client with BROKER_BUSY -- and because a
connected client keeps sockets.size above zero, it never shut down either. A
shared broker stuck in that state is worse than the leak this PR set out to fix,
since callers fall back to direct app servers and the broker never recovers.
Rather than teach one more predicate to tolerate a stale owner, the stale owner
is now released. releaseDeadOwnership() clears activeRequestSocket, and clears
activeStreamSocket together with activeStreamThreadIds, whenever the socket is
destroyed. It runs wherever ownership is inspected: when arming and when the
timer fires, when a client connects, before the busy guard, and before choosing
a notification target. isIdle() goes back to plain null checks, so no check can
disagree with another about whether the broker is in use.
Test: a client abandons a streaming request, then a second client connects and
issues a request, which must be served rather than rejected. Verified
non-vacuous against de754b0, where the reconnecting client is refused.1 parent de754b0 commit cfc4188
2 files changed
Lines changed: 59 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
125 | | - | |
| 134 | + | |
126 | 135 | | |
127 | 136 | | |
128 | 137 | | |
| |||
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
| 146 | + | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
140 | 150 | | |
141 | 151 | | |
| 152 | + | |
142 | 153 | | |
143 | 154 | | |
144 | 155 | | |
| |||
165 | 176 | | |
166 | 177 | | |
167 | 178 | | |
| 179 | + | |
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
| |||
208 | 220 | | |
209 | 221 | | |
210 | 222 | | |
| 223 | + | |
211 | 224 | | |
212 | 225 | | |
213 | 226 | | |
| |||
259 | 272 | | |
260 | 273 | | |
261 | 274 | | |
| 275 | + | |
262 | 276 | | |
263 | 277 | | |
264 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
0 commit comments