Skip to content

Commit 936b3d0

Browse files
committed
fix(internal/pool): call SetDeadline even if timeout is zero
1 parent 084c0c8 commit 936b3d0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

internal/pool/conn.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,17 @@ func (cn *Conn) RemoteAddr() net.Addr {
6464
}
6565

6666
func (cn *Conn) WithReader(ctx context.Context, timeout time.Duration, fn func(rd *proto.Reader) error) error {
67-
if timeout != 0 {
68-
if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil {
69-
return err
70-
}
67+
if err := cn.netConn.SetReadDeadline(cn.deadline(ctx, timeout)); err != nil {
68+
return err
7169
}
7270
return fn(cn.rd)
7371
}
7472

7573
func (cn *Conn) WithWriter(
7674
ctx context.Context, timeout time.Duration, fn func(wr *proto.Writer) error,
7775
) error {
78-
if timeout != 0 {
79-
if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil {
80-
return err
81-
}
76+
if err := cn.netConn.SetWriteDeadline(cn.deadline(ctx, timeout)); err != nil {
77+
return err
8278
}
8379

8480
if cn.bw.Buffered() > 0 {

0 commit comments

Comments
 (0)