From b5ac08d26c1f338c43ecdc3c93a15a33237e161a Mon Sep 17 00:00:00 2001 From: Menghan Li Date: Tue, 3 Aug 2021 14:17:02 -0700 Subject: [PATCH] [v1.40.x_lalala] transport: fix race accessing s.recvCompress (#4641) --- internal/transport/http2_client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/transport/http2_client.go b/internal/transport/http2_client.go index fa41fec903ee..0cd6da1e73f7 100644 --- a/internal/transport/http2_client.go +++ b/internal/transport/http2_client.go @@ -1301,6 +1301,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { contentTypeErr = "malformed header: missing HTTP content-type" grpcMessage string statusGen *status.Status + recvCompress string httpStatusCode *int httpStatusErr string rawStatusCode = codes.Unknown @@ -1323,7 +1324,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { mdata[hf.Name] = append(mdata[hf.Name], hf.Value) isGRPC = true case "grpc-encoding": - s.recvCompress = hf.Value + recvCompress = hf.Value case "grpc-status": code, err := strconv.ParseInt(hf.Value, 10, 32) if err != nil { @@ -1436,6 +1437,7 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) { // These values can be set without any synchronization because // stream goroutine will read it only after seeing a closed // headerChan which we'll close after setting this. + s.recvCompress = recvCompress if len(mdata) > 0 { s.header = mdata }