mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #653] trust-dns seems to leak udp connections #266
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#266
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kpcyrd on GitHub (Jan 9, 2019).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/653
Describe the bug
I might be doing something wrong here, but it seems trust-dns doesn't close udp sockets correctly:
If you add a sleep to the loop and run
watch -n1 lsof -nPiyou can see that the binary is opening a lot of udp sockets but never closes them.To Reproduce
A dirty reproducer extracted from my code:
Expected behavior
The program should close udp sockets after use. Creating the UdpClientConnection inside the loop is probably one of the reasons it's running out of file descriptors, but this shouldn't case a leak of the file descriptor.
System:
Version:
Crate: trust-dns
Version: 0.15.0
@bluejekyll commented on GitHub (Jan 10, 2019):
Ah... The
SyncClientisn't meant to be used in Futures/Tokio context, it handles all of that internally. The new_future function really should be private, but is part of the a Trait interface. I might see if that can be hidden so that it doesn't lead people down the wrong path. Sadly we don't have any examples for this, we should add some. Here are some test cases though that should better show how to use the SyncClient:Construct: https://github.com/bluejekyll/trust-dns/blob/master/tests/integration-tests/tests/client_tests.rs#L85
Use: https://github.com/bluejekyll/trust-dns/blob/master/tests/integration-tests/tests/client_tests.rs#L102
I hope that helps!
@kpcyrd commented on GitHub (Jan 10, 2019):
Oh, I see! After looking at the differences I think this was because I scheduled the background task on the default executor. Since the default executor is never shutdown the socket is never closed.
I think I remember why I did it this way though: I was actually looking for an async
Clientbut couldn't find one. In addition I don't have a reference to theRuntimesince I'm running the resolve inside a hyper connector. Creating a new Runtime inside a tokio Runtime causes a panic.Is there a reason the background task is needed? It would be easier for me if creating a Client simply returns a
FutureClientthat I can chain withand_then, without needing a reference toRuntimeorHandle.Thanks!
@bluejekyll commented on GitHub (Jan 10, 2019):
If you want an Async client, here's the best example I have: https://github.com/bluejekyll/trust-dns/blob/master/tests/integration-tests/tests/client_future_tests.rs#L66
Also, there was a UdpConnection leak in the Resolver library. That may also effect the Client library, but I don't currently plan on backporting that. I'll be publishing 0.16 alpha releases soon.
@bluejekyll commented on GitHub (Jan 19, 2019):
FYI, I'm going to close this, 0.16.0.alpha.1 has the UDP connection leak fix from the Resolver 0.10.2 release.