Skip to content

Commit

Permalink
Protect bytesSent and bytesReceived with mutex to avoid datarace (#1318)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Jun 22, 2017
1 parent 68834b6 commit 987e313
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
return nil, connectionErrorf(true, err, "transport: %v", err)
}
}
s.mu.Lock()
s.bytesSent = true
s.mu.Unlock()

if t.statsHandler != nil {
outHeader := &stats.OutHeader{
Expand Down Expand Up @@ -1024,7 +1026,9 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
if !ok {
return
}
s.mu.Lock()
s.bytesReceived = true
s.mu.Unlock()
var state decodeState
if err := state.decodeResponseHeader(frame); err != nil {
s.mu.Lock()
Expand Down

0 comments on commit 987e313

Please sign in to comment.