Skip to content

Commit

Permalink
fix: panic on cluster redirection to the same host
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Sep 21, 2024
1 parent 6188b89 commit 129a1f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ func (c *clusterClient) redirectOrNew(addr string, prev conn, slot uint16, mode
return cc.conn
}
c.mu.Lock()

if cc = c.conns[addr]; cc.conn == nil {
p = c.connFn(addr, c.opt)
c.conns[addr] = connrole{conn: p, replica: false}
cc = connrole{conn: p, replica: false}
c.conns[addr] = cc
if mode == RedirectMove {
c.pslots[slot] = p
}
Expand All @@ -413,8 +413,8 @@ func (c *clusterClient) redirectOrNew(addr string, prev conn, slot uint16, mode
prev.Close()
}(prev)
p = c.connFn(addr, c.opt)
c.conns[addr] = connrole{conn: p, replica: cc.replica}

cc = connrole{conn: p, replica: cc.replica}
c.conns[addr] = cc
if mode == RedirectMove {
if cc.replica {
c.rslots[slot] = p
Expand All @@ -424,7 +424,7 @@ func (c *clusterClient) redirectOrNew(addr string, prev conn, slot uint16, mode
}
}
c.mu.Unlock()
return p
return cc.conn
}

func (c *clusterClient) B() Builder {
Expand Down

0 comments on commit 129a1f8

Please sign in to comment.