v2: fix write deadline. Fixes #28.

This commit is contained in:
Vladimir Mihailenco 2014-05-07 16:03:09 +03:00
parent f76984bbcf
commit df12cdcfaf
1 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,10 @@ var (
errClosed = errors.New("redis: client is closed") errClosed = errors.New("redis: client is closed")
) )
var (
zeroTime = time.Time{}
)
type pool interface { type pool interface {
Get() (*conn, bool, error) Get() (*conn, bool, error)
Put(*conn) error Put(*conn) error
@ -58,7 +62,7 @@ func (cn *conn) Read(b []byte) (int, error) {
if cn.readTimeout != 0 { if cn.readTimeout != 0 {
cn.cn.SetReadDeadline(time.Now().Add(cn.readTimeout)) cn.cn.SetReadDeadline(time.Now().Add(cn.readTimeout))
} else { } else {
cn.cn.SetReadDeadline(time.Time{}) cn.cn.SetReadDeadline(zeroTime)
} }
return cn.cn.Read(b) return cn.cn.Read(b)
} }
@ -67,7 +71,7 @@ func (cn *conn) Write(b []byte) (int, error) {
if cn.writeTimeout != 0 { if cn.writeTimeout != 0 {
cn.cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout)) cn.cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout))
} else { } else {
cn.cn.SetReadDeadline(time.Time{}) cn.cn.SetWriteDeadline(zeroTime)
} }
return cn.cn.Write(b) return cn.cn.Write(b)
} }