Skip to content

refactor(lazyClientConn): Use synctest friendly once func #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarcoPolo
Copy link
Contributor

Changes the sync.Once usage to a synctest friendly once version. More context on synctest here: https://go.dev/blog/synctest.

synctest doesn't consider code blocked by a mutex as "durably blocked." This makes sense for the common case where a mutex protects some critical section of code that runs quickly. In multistream's case the protected section of a mutex does IO (it finishes the handshake). This would mean that you would end up deadlocked in a synctest bubble because one goroutine would be waiting to acquire the lock, but the goroutine that would free the lock wouldn't be able to make progress because no network IO or time would happen.

With this change basichost works with synctest.

@MarcoPolo MarcoPolo requested a review from sukunrt April 1, 2025 23:11
@MarcoPolo MarcoPolo force-pushed the marco/synctest-friendly-oncefunc branch from 9577191 to f8b2fec Compare April 2, 2025 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant