Skip to content

Commit

Permalink
rpc: correctly check for nil before cast
Browse files Browse the repository at this point in the history
As part of the fix of #99104, a cast without a nil check was introduced.
This PR addresses that by only casting if it is known to be not nil.

Epic: none
Fixes: #100275
Release note: None
  • Loading branch information
andrewbaptist committed Mar 31, 2023
1 parent 27c7beb commit 2cdcd4f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/rpc/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2715,13 +2715,14 @@ func (rpcCtx *Context) loadOrCreateConnAttempt(
select {
case <-previousAttempt.initialHeartbeatDone:
// The connection attempt was completed, return the outcome of it.
err := previousAttempt.err.Load().(error)
err := previousAttempt.err.Load()
if err == nil {
// If it completed without error then don't track the connection
// anymore. If it did have an error we need to track it until it later gets cleared.
rpcCtx.dialbackMu.m[nodeID] = nil
return nil
}
return err
return err.(error)
default:
// We still don't know the outcome of the previous attempt. For now
// allow this attempt to continue and check in the future.
Expand Down

0 comments on commit 2cdcd4f

Please sign in to comment.