Update c-ares to 1.29.0 to add reinit support to Channel#219
Update c-ares to 1.29.0 to add reinit support to Channel#219saghul merged 17 commits intosaghul:masterfrom
Conversation
|
probably should go to 1.24.0 since it fixes a regression introduced in 1.22.0 |
This comment was marked as outdated.
This comment was marked as outdated.
|
o there are docs for channel.. need to update them |
|
Great work! |
|
Thanks. I'll work on a PR for aiodns once this makes it into a release |
|
It looks like we might not have to do it manually if we turn on the event thread c-ares/c-ares#759 |
|
If the event thread can be turned on with some flag, adding support for it would be good. I wouldn't make it the default though. |
|
I agree. I'm not sure it will work with asyncio anyways. Researching that today |
|
Its explicitly not compatible with ARES_OPT_SOCK_STATE_CB so it looks like we have to do it manually |
|
Looks like its using inotify.
|
I suspected as much, since it uses threading...
IMHO that's kind a big lift for a simple DNS library. You'd also need to port the implementation to Windows and macOS. I'd expose the reinit method and let users handle it. |
Another option would be to create a new lib once we have Maybe |
|
Another option could be to explore using the builtin threaded mode, and use That's a bit more of a question for aiodns, but this lib would need to at least make it possible to enable that mode. |
|
I guess it would work with call soon thread safe, however, running in another thread would probably not be so great for performance since we now have the context switching... |
|
It kinda already works that way for those not using pycares, they will end up running getaddrinfo on a thread... Someone with enough motivation could benchmark it ;-) |
At least with Home Assistant, we know that's much slower because of the cost the context switch, which is why we use the |
|
Looking at the example https://c-ares.org/docs.html#examples .. the callbacks might be thread-safe so even if they run in another thread the callback might still be ok to consume in the event loop. need to dig some more |
|
So it looks like we can make the calls from the event loop thread and that looks like it's thread-safe but the callbacks will be delivered in another thread so we would need to deliver it back to the event loop future with loop.call_soon_threadsafe. While not great that is still relatively efficient as we don't have all the python overhead to wrap the future running in another thread. |
|
Sounds like a plan! Would you like to add support for the threaded mode here, then I can cut a release and you can experiment with aiodns? I think whatever happens in aiodns the threaded mode is a nice addition to this low(er) level library. |
|
Sounds good. About to get on a flight back to the US from FRA so will probably be later this week that I work it out (once I recover from the jet lag) |
|
Safe flight and thanks for your work! |
|
implemented in #220 aiodns PR is aio-libs/aiodns#145 used strace to verify auto reloads, so it should solve aio-libs/aiodns#124 |
to solve aio-libs/aiodns#124
Updates the submodule to tag v1.29.0. Note that v1.22.0 is the version that added reinit: https://c-ares.org/docs/ares_reinit.html but it also introduced some regressions so I went with v1.29.0 as it also fixes GHSA-mg26-v6qh-x48q and has some fixes for
reinitWe could go newer as well but #183 seemed to hold back to an older version so I only went as far as what was needed to get
reinitwithout introducing regressions and fixing CVEs. Also some of the tests started failing that looked like they might be real regressions when I went to v1.30.0 so I stopped at v1.29.0For testing with homebrew I also did
env PYCARES_USE_SYSTEM_LIB=1 LDFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" CFLAGS="-I/opt/homebrew/include -L/opt/homebrew/lib" pip install .