Commit 6e055f5
authored
Fix: Avoid hangs in fast_fallback tests under scheduling jitter (ruby#17889)
Some fast_fallback tests inject an artificial delay to test timing-sensitive behavior. Under CI's parallel test execution, threadscheduling jitter can make the delay longer than expected, and in that case these tests may fail to connect to the server process they are actually supposed to connect to.
For example:
1. The IPv6 name resolution is artificially delayed by 25ms, so the IPv4 name resolution succeeds first.
2. If the IPv6 name resolution succeeds within 25ms, the client starts connecting to the `::1` server process and the test passes. However, if the IPv6 name resolution is delayed by more than 50ms for some reason, fast_fallback starts connecting to `127.0.0.1` instead, by design.
3. If another test happens to have a server listening on `127.0.0.1` with the same port number, the connection accidentally succeeds.
4. The `::1` server process is left waiting, and the thread cleanup hangs.
To address this, the listening server process now receives the result of `accept` through a local variable instead of `Thread#value`. On success, it joins the thread with a short timeout; otherwise, it terminates the thread with `Thread#kill.join`.
This change is expected to prevent hangs even when such a wrong connection occurs.1 parent c7c0483 commit 6e055f5
1 file changed
Lines changed: 36 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
| 234 | + | |
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
240 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
241 | 246 | | |
242 | | - | |
| 247 | + | |
| 248 | + | |
243 | 249 | | |
244 | 250 | | |
245 | 251 | | |
| |||
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
255 | | - | |
| 261 | + | |
| 262 | + | |
256 | 263 | | |
257 | 264 | | |
258 | 265 | | |
259 | 266 | | |
260 | 267 | | |
261 | 268 | | |
262 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
263 | 274 | | |
264 | | - | |
| 275 | + | |
265 | 276 | | |
266 | 277 | | |
267 | 278 | | |
| |||
274 | 285 | | |
275 | 286 | | |
276 | 287 | | |
277 | | - | |
| 288 | + | |
| 289 | + | |
278 | 290 | | |
279 | 291 | | |
280 | 292 | | |
281 | 293 | | |
282 | 294 | | |
283 | 295 | | |
284 | | - | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
285 | 301 | | |
286 | | - | |
| 302 | + | |
287 | 303 | | |
288 | 304 | | |
289 | 305 | | |
| |||
420 | 436 | | |
421 | 437 | | |
422 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
423 | 450 | | |
0 commit comments