Skip to content

Commit

Permalink
transport: Fix a data race when headers are received while the stream…
Browse files Browse the repository at this point in the history
… is being closed (#1814)
  • Loading branch information
lyuxuan authored and dfawley committed Jan 19, 2018
1 parent 46bef23 commit b71aced
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions transport/http2_client.go
Expand Up @@ -1116,12 +1116,13 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
}()

s.mu.Lock()
if !endStream {
s.recvCompress = state.encoding
}
if !s.headerDone {
if !endStream && len(state.mdata) > 0 {
s.header = state.mdata
// Headers frame is not actually a trailers-only frame.
if !endStream {
s.recvCompress = state.encoding
if len(state.mdata) > 0 {
s.header = state.mdata
}
}
close(s.headerChan)
s.headerDone = true
Expand Down

0 comments on commit b71aced

Please sign in to comment.