mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #385] Port to tokio #472
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#472
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 @Keruspe on GitHub (Apr 9, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/385
tokio-core is being replaced with tokio. Is there any plan to port trust-dns in the near future?
@bluejekyll commented on GitHub (Apr 9, 2018):
I haven’t started considering yet the implications of doing this to the library, yet. I’ve read about it, and it didn’t look necessary. Could you inform me as to the benefits that you see in needing this now?
We definitely need to keep the library up to date with the ecosystem, though I don’t want to get into unnecessary churn until the path is clear, as these are distractions from the actual core features I want to work on.
I will of course look at any PRs people would like to submit, and we can decide from there. Me personally, I might not have time to get to this before some other higher priority things I want to hit.
@Keruspe commented on GitHub (Apr 10, 2018):
For my specific use case the reason is quite simple:
I use
ResolverFuture::from_system_confwhich currently takes atokio_core::reactor::Handleparameter.If I want to port my code to using tokio, I cannot pass that Handle anymore. With tokio, UdpStream and TcpStream don't require a Handle anymore so that parameter wouldn't be necessary anymore.
@bluejekyll commented on GitHub (Apr 10, 2018):
I was afraid that was the answer. I’ll be upgrading when I have a moment, but that may not be until the middle of May. It might be a large annoying change, and lots of old poorly documented code in certain spots, but if you wanted to take a stab at doing it, I’d gladly accept a PR.
@Keruspe commented on GitHub (Apr 10, 2018):
There is no rush in this, tokio is pretty young still, I just wanted to make sure it's on the roadmap as there didn't seem to be any issue about it.
I might give it a try at some point to see the implications
@Keruspe commented on GitHub (Apr 12, 2018):
Note that latest versions of tokio-core actually use tokio underneath, and the porting can be done incrementally. A library or a binary can be ported to tokio once all its dependencies have been ported, but there is no problem in having part of the dependencies using tokio, the other part using tokio-core, as long as you still use tokio-core.
So the core can be ported first, then the rest, piece by piece
@cssivision commented on GitHub (Apr 21, 2018):
this is awesome, I can help with this upgrade.
@Keruspe commented on GitHub (Apr 23, 2018):
@cssivision first step will be to port trust-dns-proto to tokio if you want to give it a try.
@Keruspe commented on GitHub (Apr 26, 2018):
The last tricky bit once #432 is merged is porting DnsFuture to using
tokio_executor::spawninstead oftokio_core::reactor::Handle::spawn.What makes it tricky is that the tokio_executor version requires the Future to be Send, which in turns requires all of its dependents to be Send too, and some to be Sync and you can easily get lost with lots of messy compiler errors when trying to do so.
@bluejekyll commented on GitHub (Apr 26, 2018):
One issue with Sync is the usage of error-chain which at the moment is not. There’s a PR on error-chain that hasn’t been merged yet, that might fix this: https://github.com/rust-lang-nursery/error-chain/pull/241
The other option is to switch to Failure now, another big port (the errors in trust-dns are old, and definitely deserve a cleanup)...
For Send, everything should be Send, and for a different reason, I was trying to track down why it’s not Send now, and I think it was related to Handle. It’s possible that if we go through and fix this, #430, then we might be Send (though once TCP connections are established I’m not sure if those would deny Send). I wasn’t careful about this before, and now it’s coming back to haunt.
——
With the current_thread option, we should discuss what the implications of that might be to the library.
@Keruspe commented on GitHub (Apr 26, 2018):
The current_thread option is not applicable actually, as you need to actually do some
runtoo.The use of
Rcmakes us !Send too,Arcfixes this easily.I'm also pretty sure that everywhere we have stuff like
Box<Future>we need to explicitely stateBox<Future + Send>.Note that once this is done, only tokio_core::reactor::Core will still be used from the tokio-core crate which is not a blocker. We probably won't be able to port those yet anyway as there is nothing like Core::run (with tokio::run you can only have
Future<(), ()>).@bluejekyll commented on GitHub (Apr 26, 2018):
Yes, that's another cleanup to happen. Really, all of those
Box<Future...>should be converted to actual future types... I Boxed a lot to get things done, so now it's a matter of going through and unboxing to actual types. I was thinking we might doimpl Traitfor this, but then we'll be pinning new versions to a very current release of rustc... that might be ok, not sure.@Keruspe commented on GitHub (Apr 30, 2018):
I started digging into how we could fix the errors from dns_future when using tokio-executor in the resolver module.
I fixed two tests as examples on how it should now work: https://github.com/Keruspe/trust-dns/tree/tokio-executor
@bluejekyll what do you think of this?
I didn't fully look at the implications, but I think a good way to make lots of tests "magically" pass is to make ResolverFuture constructors return a lazy future
@Keruspe commented on GitHub (Apr 30, 2018):
Just tried this, all the resolver tests pass now.
One client doc test doesn't pass, several integration-tests and some server ones, everything else pass just fine
@Keruspe commented on GitHub (Apr 30, 2018):
Everything seems to work fine now, without the threading + run hack
@Keruspe commented on GitHub (May 2, 2018):
I also have some wip for migrating away from tokio_core::reactor::Core, works fine for some modules, a couple of tests fail for other, requires a feature that'll be in next release of tokio to fix them, it seems.
lookup_ipblock forever when use different tokio runtime. #497