1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Fix pool panic on slow connection with MaxRetries > 0.

This commit is contained in:
Vladimir Mihailenco
2015-10-13 12:02:29 +03:00
parent 8ca66a53e6
commit 25164333ff
10 changed files with 112 additions and 39 deletions

View File

@ -232,7 +232,15 @@ func startSentinel(port, masterName, masterPort string) (*redisProcess, error) {
//------------------------------------------------------------------------------
var errTimeout = syscall.ETIMEDOUT
var (
errTimeout = syscall.ETIMEDOUT
)
type badConnError string
func (e badConnError) Error() string { return string(e) }
func (e badConnError) Timeout() bool { return false }
func (e badConnError) Temporary() bool { return false }
type badConn struct {
net.TCPConn
@ -250,7 +258,7 @@ func (cn *badConn) Read([]byte) (int, error) {
if cn.readErr != nil {
return 0, cn.readErr
}
return 0, net.UnknownNetworkError("badConn")
return 0, badConnError("bad connection")
}
func (cn *badConn) Write([]byte) (int, error) {
@ -260,5 +268,5 @@ func (cn *badConn) Write([]byte) (int, error) {
if cn.writeErr != nil {
return 0, cn.writeErr
}
return 0, net.UnknownNetworkError("badConn")
return 0, badConnError("bad connection")
}