1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Don't remove connection from the pool on redis errors.

This commit is contained in:
Vladimir Mihailenco
2014-06-18 15:55:49 +03:00
parent 5019689b0e
commit deb41df992
3 changed files with 31 additions and 12 deletions

View File

@ -65,12 +65,14 @@ func (c *baseClient) init(cn *conn, password string, db int64) error {
return nil
}
func (c *baseClient) freeConn(cn *conn, err error) {
if err == Nil || err == TxFailedErr {
c.putConn(cn)
} else {
c.removeConn(cn)
func (c *baseClient) freeConn(cn *conn, ei error) error {
if cn.rd.Buffered() > 0 {
return c.connPool.Remove(cn)
}
if _, ok := ei.(redisError); ok {
return c.connPool.Put(cn)
}
return c.connPool.Remove(cn)
}
func (c *baseClient) removeConn(cn *conn) {