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 race condition when accepting streams #2874

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

marten-seemann
Copy link
Member

What's happening here is the following: In AcceptStream we check if the stream we want to return already exists: https://github.com/lucas-clemente/quic-go/blob/629272c7138e9f2824d5cbf5d629e801339301d7/streams_map_incoming_generic.go#L64-L73
It does not. Before advance to the select statement, the go routine is preempted and GetOrOpenStream is called and the stream is created. Since newStreamChan is an unbuffered channel, GetOrOpenStream doesn't send on that channel:
https://github.com/lucas-clemente/quic-go/blob/629272c7138e9f2824d5cbf5d629e801339301d7/streams_map_incoming_generic.go#L116-L122
Now AcceptStream will never return the stream, as it's now blocking on the select statement.

The solution is simple: make newStreamChan a channel of capacity 1.

@marten-seemann marten-seemann changed the title Fix accept stream race fix race condition when accepting streams Nov 13, 2020
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