From ccbf79c87ca93e5972ea67f1dee1919fe32f2673 Mon Sep 17 00:00:00 2001 From: TopiSenpai Date: Sun, 30 Apr 2023 00:56:19 +0200 Subject: [PATCH] reset write & read deadline in voice conn open --- voice/udp_conn.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/voice/udp_conn.go b/voice/udp_conn.go index f8a23ca6..eb050111 100644 --- a/voice/udp_conn.go +++ b/voice/udp_conn.go @@ -164,6 +164,9 @@ func (u *udpConnImpl) Open(ctx context.Context, ip string, port int, ssrc uint32 if err = u.conn.SetWriteDeadline(time.Now().Add(5 * time.Second)); err != nil { return "", 0, fmt.Errorf("failed to set write deadline on UDPConn connection: %w", err) } + defer func() { + _ = u.conn.SetWriteDeadline(time.Time{}) + }() if _, err = u.conn.Write(sb); err != nil { return "", 0, fmt.Errorf("failed to write ssrc to UDPConn connection: %w", err) } @@ -172,6 +175,9 @@ func (u *udpConnImpl) Open(ctx context.Context, ip string, port int, ssrc uint32 if err = u.conn.SetReadDeadline(time.Now().Add(5 * time.Second)); err != nil { return "", 0, fmt.Errorf("failed to set read deadline on UDPConn connection: %w", err) } + defer func() { + _ = u.conn.SetReadDeadline(time.Time{}) + }() if _, err = u.conn.Read(rb); err != nil { return "", 0, fmt.Errorf("failed to read ip discovery from UDPConn connection: %w", err) }