1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Set read/write timeouts more consistently.

This commit is contained in:
Vladimir Mihailenco
2016-12-03 17:30:13 +02:00
parent e7f23a300b
commit b4efc45f1c
18 changed files with 343 additions and 198 deletions

11
ring.go
View File

@ -332,7 +332,7 @@ func (c *Ring) heartbeat() {
//
// It is rare to Close a Ring, as the Ring is meant to be long-lived
// and shared between many goroutines.
func (c *Ring) Close() (retErr error) {
func (c *Ring) Close() error {
defer c.mu.Unlock()
c.mu.Lock()
@ -341,15 +341,16 @@ func (c *Ring) Close() (retErr error) {
}
c.closed = true
var firstErr error
for _, shard := range c.shards {
if err := shard.Client.Close(); err != nil {
retErr = err
if err := shard.Client.Close(); err != nil && firstErr == nil {
firstErr = err
}
}
c.hash = nil
c.shards = nil
return retErr
return firstErr
}
func (c *Ring) Pipeline() *Pipeline {
@ -402,7 +403,7 @@ func (c *Ring) pipelineExec(cmds []Cmder) (firstErr error) {
continue
}
retry, err := execCmds(cn, cmds)
retry, err := shard.Client.execCmds(cn, cmds)
shard.Client.putConn(cn, err, false)
if err == nil {
continue