Skip to content
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

Fix Channel Close Behavior #96

Merged
merged 1 commit into from
Jul 25, 2024
Merged

Fix Channel Close Behavior #96

merged 1 commit into from
Jul 25, 2024

Conversation

jaredoconnell
Copy link
Contributor

Changes introduced with this PR

This PR lets the user be responsible for closing signal channel. This proposed design is the "correct" one. Golang specifically does not recommend that receivers close the channel, which is what was happening. And there was no way to reliably ensure that the channel was open on the sending side, leading to race conditions.

This was discovered while working on the engine. There were issues where I sent on a closed channel.


By contributing to this repository, I agree to the contribution guidelines.

Copy link

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as it gets closed somewhere, that's fine. I'm a little worried that this may be changing the external interface of the SDK (adding a requirement that the client closes the channels when done?), which may suggest a major version and careful documentation? (Although it's unlikely anyone but the engine is using it.)

@jaredoconnell
Copy link
Contributor Author

As long as it gets closed somewhere, that's fine. I'm a little worried that this may be changing the external interface of the SDK (adding a requirement that the client closes the channels when done?), which may suggest a major version and careful documentation? (Although it's unlikely anyone but the engine is using it.)

Interestingly, it's also perfectly valid to not close it. It's up to the user to determine how they want to use it. They just need to make sure the buffer is large enough that if the other end isn't receiving, it doesn't deadlock itself.

@jaredoconnell jaredoconnell merged commit 0d23e25 into main Jul 25, 2024
3 checks passed
@jaredoconnell jaredoconnell deleted the fix-channel-behavior branch July 25, 2024 19:11
@webbnh webbnh mentioned this pull request Jul 26, 2024
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.

2 participants