Add stbbr_wait_stopped() API for proper shutdown synchronization #3

Open
opened 2026-01-05 15:04:13 +00:00 by jabber.developer2 · 0 comments
Collaborator

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 now

This 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.

## 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 now` This 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.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: devs/stabber#3
No description provided.