From 3961b9577f622a3079fe74f8fc8da12ba67a77ff Mon Sep 17 00:00:00 2001 From: slowrookie Date: Sat, 26 Mar 2022 18:11:44 +0800 Subject: [PATCH] fix: use redis over ssh channel(#2057) (#2060) --- internal/pool/conn.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/pool/conn.go b/internal/pool/conn.go index 56616598..65258ec4 100644 --- a/internal/pool/conn.go +++ b/internal/pool/conn.go @@ -64,8 +64,10 @@ func (cn *Conn) RemoteAddr() net.Addr { } func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error { - if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil { - return err + if timeout != 0 { + if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil { + return err + } } return fn(cn.rd) } @@ -73,8 +75,10 @@ func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(r func (cn *Conn) WithWriter( ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error, ) error { - if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil { - return err + if timeout != 0 { + if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil { + return err + } } if cn.bw.Buffered() > 0 {