Commit b4e4816
Fix flaky reverse_interface test (UniversalRobots#497)
Scope g_connection_mutex only around each wait_for on
g_connection_condition in
ReverseInterfaceTest.disconnected_callbacks_are_called. Previously the
test held the mutex from the first disconnect wait through the rest of
the test, which blocked the TCPServer worker in
TestableReverseInterface::connectionCallback while it waited for the
same mutex. The worker never returned to select/recv, so later client
closes were not observed and waitForProgramState(false) timed out.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to test synchronization, reducing lock
contention that could deadlock the server thread and cause timeouts.
>
> **Overview**
> Fixes flakiness in
`ReverseInterfaceTest.disconnected_callbacks_are_called` by **scoping
`g_connection_mutex` to each `g_connection_condition.wait_for`** instead
of holding a single lock across multiple disconnect/reconnect phases.
>
> This prevents the test thread from blocking the reverse interface’s
connection/disconnection callback thread on the same mutex, so
subsequent client closes are observed reliably and
`waitForProgramState(false)` no longer intermittently times out.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
03272de. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 01cf607 commit b4e4816
1 file changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
541 | 544 | | |
542 | 545 | | |
543 | 546 | | |
| |||
548 | 551 | | |
549 | 552 | | |
550 | 553 | | |
551 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
552 | 559 | | |
553 | 560 | | |
554 | 561 | | |
| |||
560 | 567 | | |
561 | 568 | | |
562 | 569 | | |
563 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
564 | 575 | | |
565 | 576 | | |
566 | 577 | | |
| |||
0 commit comments