From 171a6d13e968d9590ee6a14a53f9a2be10bda3e1 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 25 Oct 2018 09:42:56 +0300 Subject: [PATCH] Fix closing nil sentinel --- sentinel.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sentinel.go b/sentinel.go index 24d6db68..951fb1db 100644 --- a/sentinel.go +++ b/sentinel.go @@ -181,7 +181,10 @@ type sentinelFailover struct { func (c *sentinelFailover) Close() error { c.mu.Lock() defer c.mu.Unlock() - return c.closeSentinel() + if c.sentinel != nil { + return c.closeSentinel() + } + return nil } func (c *sentinelFailover) Pool() *pool.ConnPool { @@ -240,7 +243,7 @@ func (c *sentinelFailover) masterAddr() (string, error) { if err != nil { internal.Logf("sentinel: GetMasterAddrByName master=%q failed: %s", c.masterName, err) - sentinel.Close() + _ = sentinel.Close() continue }