Repository navigation
Commit 4c6ecff
committed
test(daemon-ipc): wait for the startup gate event, not an attempt budget
daemon_ipc_windows_startup_retries_transient_rendezvous_reader failed on
a windows-latest CLANG64 runner (ASSERT(startup_observed); the whole
suite took 7 s) on a PR that touched only CLI files.
ipc_test_startup_gate_wait_acquired polled 50000 x cbm_usleep(200) and
returned false once the budget ran out. On POSIX that is ~10 s, but on
Windows cbm_usleep(us) is Sleep(us / 1000), so cbm_usleep(200) is
Sleep(0): the budget collapsed to 50000 bare yields, which a loaded
runner spends in milliseconds before the startup thread reaches the
gate. A timeout decided the verdict.
The helper now waits until the startup thread has either parked in the
gate or returned without reaching it (a new `finished` flag, set by
ipc_test_win_startup_call after its call returns). Both flags only go
false -> true and one of them is always set: before the gate the startup
path only try-acquires, and a thread parked in the gate cannot return
until the test releases it. No bound is left to decide the verdict. A
thread that returns without reaching the gate fails at once, and the
test reports its try-acquire status as the reason.
The same shape is removed from two cross-platform tests:
- daemon_ipc_wait_forever_is_interruptible waited for the server's
forever-wait under a 2 s wall-clock deadline. Past the deadline the
test skipped the interrupt, so the join then blocked on a server
parked in WAIT_FOREVER: a hang, not a failure. It now waits for
`waiting` or for a new `finished` flag set when the server thread
returns.
- daemon_ipc_connect_waits_for_delayed_listener capped its wait for
`delay_started` at 2000 polls. That store is the thread's first
action, so the wait needs no attempt bound.
No production change and no new sleep: the existing per-poll yields
stay.
Proof. A standalone harness mirrors the gate, both helpers and the
thread wrapper, with cbm_usleep modelled as on Windows
(Sleep(us / 1000), so cbm_usleep(200) is a bare yield):
- startup thread arriving only after 50000 polls: old helper 20/20 FAIL
(startup_observed=false with call.result=1, the CI signature), new
helper 20/20 PASS;
- startup thread descheduled 500 ms: the old helper gives up after 9 ms,
10/10 FAIL; new helper 10/10 PASS; control, old helper with POSIX
usleep: 10/10 PASS;
- thread returning without reaching the gate: the new helper fails
within 11 ms with call.result=-1 (the old one took 16 s under POSIX).
Real daemon_ipc suite on macOS: with the server and listener threads
held 4 s and 6 s (beyond both old bounds) the two cross-platform tests
pass. The old 2000-poll loop under the 6 s hold fails
ASSERT(delay_observed). The old 2 s deadline under the 4 s hold hangs in
the join until killed. A server that skips accept makes the new loop
fail ASSERT(reached_wait) with no added wait.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent 1f9b4db commit 4c6ecff
1 file changed
Lines changed: 48 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
| |||
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
431 | 438 | | |
432 | 439 | | |
433 | | - | |
| 440 | + | |
434 | 441 | | |
435 | 442 | | |
436 | 443 | | |
| |||
441 | 448 | | |
442 | 449 | | |
443 | 450 | | |
| 451 | + | |
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
| |||
1395 | 1403 | | |
1396 | 1404 | | |
1397 | 1405 | | |
| 1406 | + | |
1398 | 1407 | | |
1399 | 1408 | | |
1400 | 1409 | | |
| |||
1420 | 1429 | | |
1421 | 1430 | | |
1422 | 1431 | | |
1423 | | - | |
| 1432 | + | |
1424 | 1433 | | |
1425 | 1434 | | |
1426 | 1435 | | |
| |||
1441 | 1450 | | |
1442 | 1451 | | |
1443 | 1452 | | |
1444 | | - | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
1445 | 1461 | | |
1446 | 1462 | | |
1447 | 1463 | | |
| |||
1464 | 1480 | | |
1465 | 1481 | | |
1466 | 1482 | | |
| 1483 | + | |
1467 | 1484 | | |
1468 | 1485 | | |
1469 | 1486 | | |
| |||
1501 | 1518 | | |
1502 | 1519 | | |
1503 | 1520 | | |
1504 | | - | |
| 1521 | + | |
1505 | 1522 | | |
1506 | 1523 | | |
1507 | 1524 | | |
| |||
1534 | 1551 | | |
1535 | 1552 | | |
1536 | 1553 | | |
1537 | | - | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
1538 | 1562 | | |
1539 | 1563 | | |
1540 | 1564 | | |
| |||
2442 | 2466 | | |
2443 | 2467 | | |
2444 | 2468 | | |
| 2469 | + | |
2445 | 2470 | | |
2446 | 2471 | | |
2447 | 2472 | | |
| |||
2464 | 2489 | | |
2465 | 2490 | | |
2466 | 2491 | | |
| 2492 | + | |
2467 | 2493 | | |
2468 | 2494 | | |
2469 | 2495 | | |
| |||
2480 | 2506 | | |
2481 | 2507 | | |
2482 | 2508 | | |
| 2509 | + | |
2483 | 2510 | | |
2484 | 2511 | | |
2485 | 2512 | | |
| |||
2495 | 2522 | | |
2496 | 2523 | | |
2497 | 2524 | | |
2498 | | - | |
2499 | | - | |
2500 | | - | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
2501 | 2530 | | |
2502 | 2531 | | |
2503 | 2532 | | |
| |||
2561 | 2590 | | |
2562 | 2591 | | |
2563 | 2592 | | |
| 2593 | + | |
| 2594 | + | |
2564 | 2595 | | |
2565 | | - | |
2566 | | - | |
2567 | | - | |
2568 | | - | |
2569 | | - | |
| 2596 | + | |
2570 | 2597 | | |
2571 | 2598 | | |
| 2599 | + | |
2572 | 2600 | | |
2573 | 2601 | | |
2574 | 2602 | | |
| |||
0 commit comments