From df12cdcfafdc2b427acbca3d11e9967577867307 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 7 May 2014 16:03:09 +0300 Subject: [PATCH] v2: fix write deadline. Fixes #28. --- v2/pool.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/v2/pool.go b/v2/pool.go index 7a9b791c..8f596a46 100644 --- a/v2/pool.go +++ b/v2/pool.go @@ -15,6 +15,10 @@ var ( errClosed = errors.New("redis: client is closed") ) +var ( + zeroTime = time.Time{} +) + type pool interface { Get() (*conn, bool, error) Put(*conn) error @@ -58,7 +62,7 @@ func (cn *conn) Read(b []byte) (int, error) { if cn.readTimeout != 0 { cn.cn.SetReadDeadline(time.Now().Add(cn.readTimeout)) } else { - cn.cn.SetReadDeadline(time.Time{}) + cn.cn.SetReadDeadline(zeroTime) } return cn.cn.Read(b) } @@ -67,7 +71,7 @@ func (cn *conn) Write(b []byte) (int, error) { if cn.writeTimeout != 0 { cn.cn.SetWriteDeadline(time.Now().Add(cn.writeTimeout)) } else { - cn.cn.SetReadDeadline(time.Time{}) + cn.cn.SetWriteDeadline(zeroTime) } return cn.cn.Write(b) }