Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
Close probe connection, don't fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
enriclluelles committed May 23, 2016
1 parent 8c74ae9 commit f98f451
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func proxy(local io.ReadWriteCloser, remoteAddr *net.TCPAddr) {
func getMasterAddr(sentinelAddress *net.TCPAddr, masterName string) (*net.TCPAddr, error) {
conn, err := net.DialTCP("tcp", nil, sentinelAddress)
if err != nil {
log.Fatal("Error connecting to sentinel: %s", err)
return nil, err
}

defer conn.Close()
Expand Down Expand Up @@ -110,7 +110,10 @@ func getMasterAddr(sentinelAddress *net.TCPAddr, masterName string) (*net.TCPAdd
}

//check that there's actually someone listening on that address
_, err = net.DialTCP("tcp", nil, addr)
conn2, err := net.DialTCP("tcp", nil, addr)
if err == nil {
defer conn2.Close()
}

return addr, err
}

0 comments on commit f98f451

Please sign in to comment.