Skip to content

Commit

Permalink
fixing logical race when Close is called before Invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Dec 8, 2023
1 parent 432f5e0 commit c1c4940
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,12 @@ func (cc *ClientConn) Close() {
// Invoke sends the RPC request on the wire and returns after response is
// received.
func (cc *ClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}) error {
// Ensure the connection state is ready
if cc.addrConn == nil {
// Close() has been called
return errors.New("client Close() called")
}

// Ensure the connection state is ready
cc.mu.RLock()
cc.addrConn.mu.RLock()
state := cc.addrConn.state
Expand Down

0 comments on commit c1c4940

Please sign in to comment.