From 1e9a59edf99b232cf160982e42c6bc3a807eaf0e Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 5 Jan 2024 11:45:20 +0000 Subject: [PATCH] Update behaviour in QUIC listener handler --- src/core/link_quic.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/core/link_quic.go b/src/core/link_quic.go index a2db6e0..9ad5456 100644 --- a/src/core/link_quic.go +++ b/src/core/link_quic.go @@ -3,6 +3,7 @@ package core import ( "context" "crypto/tls" + "fmt" "net" "net/url" "time" @@ -77,18 +78,22 @@ func (l *linkQUIC) listen(ctx context.Context, url *url.URL, _ string) (net.List go func() { for { qc, err := ql.Accept(ctx) - if err != nil { + switch err { + case context.Canceled, context.DeadlineExceeded: ql.Close() + fallthrough + case quic.ErrServerClosed: return - } - qs, err := qc.AcceptStream(ctx) - if err != nil { - ql.Close() - return - } - ch <- &linkQUICStream{ - Connection: qc, - Stream: qs, + case nil: + qs, err := qc.AcceptStream(ctx) + if err != nil { + _ = qc.CloseWithError(1, fmt.Sprintf("stream error: %s", err)) + continue + } + ch <- &linkQUICStream{ + Connection: qc, + Stream: qs, + } } } }()