From 4ba1eb123cdb76433620ae2c3e4840a9899499a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 27 Nov 2024 17:28:18 +0800 Subject: [PATCH] Fix set timeout --- common/canceler/packet.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/canceler/packet.go b/common/canceler/packet.go index 46cf9a0..519f283 100644 --- a/common/canceler/packet.go +++ b/common/canceler/packet.go @@ -24,7 +24,7 @@ type TimerPacketConn struct { func NewPacketConn(ctx context.Context, conn N.PacketConn, timeout time.Duration) (context.Context, N.PacketConn) { if timeoutConn, isTimeoutConn := common.Cast[PacketConn](conn); isTimeoutConn { oldTimeout := timeoutConn.Timeout() - if timeout >= oldTimeout { + if oldTimeout > 0 && timeout >= oldTimeout { return ctx, conn } if timeoutConn.SetTimeout(timeout) {