diff --git a/transport/http2_client.go b/transport/http2_client.go index 52c9610fbead..a762e5562f16 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -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{ @@ -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()