server/embed: fix data race when start insecure grpc

There are two goroutines accessing the `gs` grpc server var. Before
insecure `gs` server start, the `gs` can be changed to secure server and
then the client will fail to connect to etcd with insecure request. It
is data-race. We should use argument for reference in the new goroutine.

fix: #15495

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit a9988e2625)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu
2023-03-18 21:28:34 +08:00
parent 15b3756abd
commit 9e974792f9
2 changed files with 35 additions and 12 deletions

View File

@@ -142,6 +142,9 @@ func fetchGrpcGateway(endpoint string, httpVersion string, connType clientConnTy
}
req := cURLReq{endpoint: "/v3/kv/range", value: string(rangeData), timeout: 5, httpVersion: httpVersion}
respData, err := curl(endpoint, "POST", req, connType)
if err != nil {
return err
}
return validateGrpcgatewayRangeReponse([]byte(respData))
}