fix: use redis over ssh channel(#2057) (#2060)

This commit is contained in:
slowrookie 2022-03-26 18:11:44 +08:00 committed by GitHub
parent 3f9f6166a4
commit 3961b9577f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -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 { 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 { if timeout != 0 {
return err if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil {
return err
}
} }
return fn(cn.rd) 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( func (cn *Conn) WithWriter(
ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error, ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error,
) error { ) error {
if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil { if timeout != 0 {
return err if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil {
return err
}
} }
if cn.bw.Buffered() > 0 { if cn.bw.Buffered() > 0 {