Fix canceler.PacketConn

This commit is contained in:
dyhkwong 2024-04-10 19:45:56 +08:00 committed by 世界
parent 5bfc326913
commit 8b68fc4d7a
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -21,13 +21,13 @@ type TimerPacketConn struct {
instance *Instance instance *Instance
} }
func NewPacketConn(ctx context.Context, conn N.PacketConn, timeout time.Duration) (context.Context, PacketConn) { func NewPacketConn(ctx context.Context, conn N.PacketConn, timeout time.Duration) (context.Context, N.PacketConn) {
if timeoutConn, isTimeoutConn := common.Cast[PacketConn](conn); isTimeoutConn { if timeoutConn, isTimeoutConn := common.Cast[PacketConn](conn); isTimeoutConn {
oldTimeout := timeoutConn.Timeout() oldTimeout := timeoutConn.Timeout()
if timeout < oldTimeout { if timeout < oldTimeout {
timeoutConn.SetTimeout(timeout) timeoutConn.SetTimeout(timeout)
} }
return ctx, timeoutConn return ctx, conn
} }
err := conn.SetReadDeadline(time.Time{}) err := conn.SetReadDeadline(time.Time{})
if err == nil { if err == nil {