More sensible header structure. Cute cow at the bottom
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
Down another rabbit hole, this time into yet another seemingly simple problem: how do you turn a name into an address that you can connect() to without blocking your thread, in 2016. Let’s survey state of the world:
|
||||
|
||||
### [getaddrinfo\_a()](http://man7.org/linux/man-pages/man3/getaddrinfo_a.3.html)
|
||||
## [getaddrinfo\_a()](http://man7.org/linux/man-pages/man3/getaddrinfo_a.3.html)
|
||||
|
||||
Look, it’s exactly what we need! Just joking. It’s has the same resolution behavior as getaddrinfo, but:
|
||||
|
||||
@@ -13,19 +13,19 @@ Look, it’s exactly what we need! Just joking. It’s has the same resolution b
|
||||
* It allocates memory and gives you no way to free it. Calling freeaddrinfo() doesn’t do it. The manpage doesn’t even seem to consider that one might want to free memory. It’s possible that it’s a first-time-only allocation that hasn’t made it into valgrind’s default suppressions yet.
|
||||
* It uses [sigevent](http://man7.org/linux/man-pages/man7/sigevent.7.html) to notify completion. This gives you a choice between a signal and a new thread. I thought we were doing this to avoid having to create a new thread for each resolution?
|
||||
|
||||
### [libadns](http://www.gnu.org/software/adns/)
|
||||
## [libadns](http://www.gnu.org/software/adns/)
|
||||
|
||||
* It’s GPLed. That’s cool, but it does limit options.
|
||||
* It’s a direct DNS library, not a getaddrinfo() implementation. That means you have to reproduce all the getaddrinfo() behavior, including the configuration file, if you want the behavior that users expect.
|
||||
* It will hand you file descriptors to block on, but you have to ask (using adns\_beforeselect()). This is designed for poll(), but doesn’t work well with epoll; it doesn’t tell you when to add and remove fds, so you have to track them yourself (since you can’t iterate an epoll set), diff them since the last result, and change the epoll set. It’s a mess.
|
||||
|
||||
### [libasyncns](http://0pointer.de/lennart/projects/libasyncns/)
|
||||
## [libasyncns](http://0pointer.de/lennart/projects/libasyncns/)
|
||||
|
||||
* It uses getaddrinfo() underneath, so you get standard behavior. Woo!
|
||||
* It notifies you via a file descriptor. Unfortunately, it’s only a single file descriptor across all requests. It doesn’t allow you to associate a pointer with a request, epoll-style, so you still have to track your own query list and higher-level data associations.
|
||||
* Its API isn’t too crazy, but you wouldn’t call it simple.
|
||||
|
||||
### [c-ares](http://c-ares.haxx.se/)
|
||||
## [c-ares](http://c-ares.haxx.se/)
|
||||
|
||||
I failed to find docs for this, but I found a gist with an [example](https://gist.github.com/mopemope/992777). Looks like the API is designed for use with select(), though there’s a hook to get an fd when it’s created, so you might be able to associate it with a query, possibly unreliably. Again, you’d have to recreate getaddrinfo() behavior yourself. Also, this gem is at the top of the header:
|
||||
|
||||
@@ -39,7 +39,7 @@ I failed to find docs for this, but I found a gist with an [example](https://gis
|
||||
|
||||
So maybe not.
|
||||
|
||||
### So now what?
|
||||
## So now what?
|
||||
|
||||
Maybe we can build something. I really don’t need to write another DNS library in my lifetime (the c-ares [Other Libraries](http://c-ares.haxx.se/otherlibs.html) page links to my previous one, humorously). Let’s see if we can scope some requirements:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user