From 1b02d169ad5b6dfd32ac381f01c33470227487fb Mon Sep 17 00:00:00 2001 From: Devin Carr Date: Fri, 19 Apr 2024 10:26:58 -0700 Subject: [PATCH] TUN-8374: Close UDP socket if registration fails If cloudflared was unable to register the UDP session with the edge, the socket would be left open to be eventually closed by the OS, or garbage collected by the runtime. Considering that either of these closes happened significantly after some delay, it was causing cloudflared to hold open file descriptors longer than usual if continuously unable to register sessions. --- connection/quic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/connection/quic.go b/connection/quic.go index 28186dc7..e5088c73 100644 --- a/connection/quic.go +++ b/connection/quic.go @@ -324,6 +324,7 @@ func (q *QUICConnection) RegisterUdpSession(ctx context.Context, sessionID uuid. session, err := q.sessionManager.RegisterSession(ctx, sessionID, originProxy) if err != nil { + originProxy.Close() log.Err(err).Str("sessionID", sessionID.String()).Msgf("Failed to register udp session") tracing.EndWithErrorStatus(registerSpan, err) return nil, err