Skip to content

Commit

Permalink
Merge pull request #1206 from ydb-platform/fix-data-race-in-stream
Browse files Browse the repository at this point in the history
#1205: Fix data race in grpc_client_stream
  • Loading branch information
asmyasnikov authored Apr 18, 2024
2 parents bf0fd33 + ecc1811 commit 7436737
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 `internal/conn.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 7436737

Please sign in to comment.