Add stbbr_wait_stopped() API for proper shutdown synchronization #3
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add an API function to wait for the stabber server to fully stop and release its port, enabling proper synchronization in test teardown.
Problem
When using stabber in test suites that run multiple tests sequentially, there's a race condition between stbbr_stop() returning and the port actually being released by the OS. This can cause subsequent tests to fail when trying to start a new stabber instance on the same port.
Currently, we work around this with an arbitrary delay:
stbbr_stop(); usleep(100000); // 100ms - hope the port is released by nowThis approach is:
Unreliable - the delay may not be sufficient on slower systems or under load
Wasteful - on fast systems we wait longer than necessary
Fragile - any system hiccup can cause flaky test failures
Proposed Solution
Add a blocking function that waits until stabber has fully released all resources:
int stbbr_wait_stopped(int timeout_ms);Or alternatively, make stbbr_stop() itself blocking until the port is fully released.