Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x): properly cleanup the QUIC objects #307

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions x/examples/fetch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func main() {
return http.ErrUseLastResponse
},
}
defer httpClient.CloseIdleConnections()

var tlsConfig tls.Config
if *tlsKeyLogFlag != "" {
Expand Down Expand Up @@ -168,11 +169,11 @@ func main() {
slog.Error("Could not create PacketConn", "error", err)
os.Exit(1)
}
tr := &quic.Transport{
quicTransport := &quic.Transport{
Conn: conn,
}
defer tr.Close()
httpClient.Transport = &http3.Transport{
defer quicTransport.Close()
httpTransport := &http3.Transport{
TLSClientConfig: &tlsConfig,
Dial: func(ctx context.Context, addr string, tlsConf *tls.Config, quicConf *quic.Config) (quic.EarlyConnection, error) {
addressToDial, err := overrideAddress(addr, overrideHost, overridePort)
Expand All @@ -183,10 +184,12 @@ func main() {
if err != nil {
return nil, err
}
return tr.DialEarly(ctx, udpAddr, tlsConf, quicConf)
return quicTransport.DialEarly(ctx, udpAddr, tlsConf, quicConf)
},
Logger: slog.Default(),
}
defer httpTransport.Close()
httpClient.Transport = httpTransport
} else {
slog.Error("Invalid HTTP protocol", "proto", *protoFlag)
os.Exit(1)
Expand Down
Loading