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

transport: Fix a data race when headers are received while the stream is closing #1814

Merged
merged 2 commits into from Jan 19, 2018

Conversation

lyuxuan
Copy link
Contributor

@lyuxuan lyuxuan commented Jan 19, 2018

fix #1803

Disallow assignment to s.recvCompress after header chan is closed.

@@ -1114,7 +1114,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
}()

s.mu.Lock()
if !endStream {
if !endStream && !s.headerDone {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Let's keep a single !headerDone block, and maybe also a !endStream block as well:

if !s.headerDone {
  if !endStream {
    // Headers frame is not actually a trailers-only frame.
    s.recvCompress = state.encoding
    if len(state.mdata) > 0 {
      s.header = state.mdata
...

...And this led me to find another bug, isHeader should only be set in the if !endStream block... We can fix that separately.

@dfawley dfawley merged commit b71aced into grpc:master Jan 19, 2018
@dfawley dfawley changed the title Disallow assignment to s.recvCompress after header chan is closed. transport: Fix a data race when headers are received while the stream is being closed Jan 19, 2018
@dfawley dfawley changed the title transport: Fix a data race when headers are received while the stream is being closed transport: Fix a data race when headers are received while the stream is closing Jan 19, 2018
dfawley pushed a commit that referenced this pull request Jan 19, 2018
@menghanl menghanl added this to the 1.10 Release milestone Feb 14, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data race in http2Client
3 participants