Skip to content

Commit

Permalink
Hold lock while accessing c.stream.err
Browse files Browse the repository at this point in the history
For some reason I'd been under the impression that startCall acquired
this and released it in finish(), but that's not the case.
  • Loading branch information
zenhack committed Feb 14, 2023
1 parent 4578221 commit d2e85b5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions capability.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,13 @@ func (c Client) SendCall(ctx context.Context, s Send) (*Answer, ReleaseFunc) {
return ErrorAnswer(s.Method, errors.New("call on null client")), func() {}
}

if c.stream.err != nil {
return ErrorAnswer(s.Method, exc.WrapError("stream error", c.stream.err)), func() {}
var err error
syncutil.With(&c.mu, func() {
err = c.stream.err
})

if err != nil {
return ErrorAnswer(s.Method, exc.WrapError("stream error", err)), func() {}
}

limiter := c.GetFlowLimiter()
Expand Down

0 comments on commit d2e85b5

Please sign in to comment.