Skip to content

Make stream closing atomic#139

Closed
henry118 wants to merge 1 commit intocontainerd:mainfrom
henry118:panic
Closed

Make stream closing atomic#139
henry118 wants to merge 1 commit intocontainerd:mainfrom
henry118:panic

Conversation

@henry118
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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