fix cmdInfo nil pointer panic

This commit is contained in:
zezhou.yu 2016-12-08 01:34:22 +08:00
parent 854c88a72c
commit fb584d25db
No known key found for this signature in database
GPG Key ID: 9CF35EF1A6E62AE7
1 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package redis
import (
"fmt"
"math/rand"
"sync"
"sync/atomic"
@ -371,7 +372,9 @@ func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *cl
return -1, node, err
}
slot := hashtag.Slot(firstKey)
if cmdInfo == nil {
return -1, nil, internal.RedisError(fmt.Sprintf("cmdInfo of %s is nil", cmd.arg(0)))
}
if cmdInfo.ReadOnly && c.opt.ReadOnly {
if c.opt.RouteByLatency {
node, err := state.slotClosestNode(slot)