Skip to content

Commit

Permalink
Merge pull request redis#890 from go-redis/fix/close-nil-sentinel
Browse files Browse the repository at this point in the history
Fix closing nil sentinel
  • Loading branch information
vmihailenco authored Oct 25, 2018
2 parents fa76dd0 + 171a6d1 commit b3d9bf1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b3d9bf1

Please sign in to comment.