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

Make stream closing atomic #139

Closed
wants to merge 1 commit into from
Closed

Conversation

henry118
Copy link
Member

Fixes: #8930

closeWithError() is not atomic, which may result in a race situation where the recv channel is closed right before we write to the channel, but after checking recvErr is nil.

Signed-off-by: Henry Wang <henwang@amazon.com>
@dmcgowan
Copy link
Member

Another option could be instead of creating a mutex, never close recv and instead have a recvClose channel. Whenever a select is used on recv, check for the recvClose channel instead of checking if recv is closed. I know it looks a little uglier, but it is less likely to deadlock. Using a lock here has the risk of getting in a recv/close deadlock (consumer of recv channel is trying to close).

@henry118
Copy link
Member Author

Got it. I'll close this PR then.

@henry118 henry118 closed this Apr 28, 2023
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.

TTRPC Panic: send on closed channel
2 participants