mirror of https://github.com/go-redis/redis.git
Merge pull request #890 from go-redis/fix/close-nil-sentinel
Fix closing nil sentinel
This commit is contained in:
commit
b3d9bf10f6
|
@ -181,8 +181,11 @@ type sentinelFailover struct {
|
||||||
func (c *sentinelFailover) Close() error {
|
func (c *sentinelFailover) Close() error {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
defer c.mu.Unlock()
|
defer c.mu.Unlock()
|
||||||
|
if c.sentinel != nil {
|
||||||
return c.closeSentinel()
|
return c.closeSentinel()
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *sentinelFailover) Pool() *pool.ConnPool {
|
func (c *sentinelFailover) Pool() *pool.ConnPool {
|
||||||
c.poolOnce.Do(func() {
|
c.poolOnce.Do(func() {
|
||||||
|
@ -240,7 +243,7 @@ func (c *sentinelFailover) masterAddr() (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
internal.Logf("sentinel: GetMasterAddrByName master=%q failed: %s",
|
internal.Logf("sentinel: GetMasterAddrByName master=%q failed: %s",
|
||||||
c.masterName, err)
|
c.masterName, err)
|
||||||
sentinel.Close()
|
_ = sentinel.Close()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue