Skip to content

Commit

Permalink
Fix data race in grpc Client stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Golov committed Apr 18, 2024
1 parent bf0fd33 commit b8474db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed data race in `grpcClientStream`

## v3.65.2
* Fixed data race using `log.WithNames`

Expand Down
11 changes: 7 additions & 4 deletions internal/conn/grpc_client_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type grpcClientStream struct {
}

func (s *grpcClientStream) CloseSend() (err error) {
onDone := trace.DriverOnConnStreamCloseSend(s.c.config.Trace(), &s.ctx,
ctx := s.ctx
onDone := trace.DriverOnConnStreamCloseSend(s.c.config.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).CloseSend"),
)
defer func() {
Expand Down Expand Up @@ -59,7 +60,8 @@ func (s *grpcClientStream) CloseSend() (err error) {
}

func (s *grpcClientStream) SendMsg(m interface{}) (err error) {
onDone := trace.DriverOnConnStreamSendMsg(s.c.config.Trace(), &s.ctx,
ctx := s.ctx
onDone := trace.DriverOnConnStreamSendMsg(s.c.config.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).SendMsg"),
)
defer func() {
Expand Down Expand Up @@ -101,7 +103,8 @@ func (s *grpcClientStream) SendMsg(m interface{}) (err error) {
}

func (s *grpcClientStream) RecvMsg(m interface{}) (err error) {
onDone := trace.DriverOnConnStreamRecvMsg(s.c.config.Trace(), &s.ctx,
ctx := s.ctx
onDone := trace.DriverOnConnStreamRecvMsg(s.c.config.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/3/internal/conn.(*grpcClientStream).RecvMsg"),
)
defer func() {
Expand All @@ -114,7 +117,7 @@ func (s *grpcClientStream) RecvMsg(m interface{}) (err error) {
defer func() {
if err != nil {
md := s.ClientStream.Trailer()
s.onDone(s.ctx, md)
s.onDone(ctx, md)
}
}()

Expand Down

0 comments on commit b8474db

Please sign in to comment.