getaddrinfo performance problems

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Tue Apr 17 10:26:58 UTC 2012


On Mon, Apr 16, 2012 at 11:27:55PM +0100, Ed W wrote:
>On 16/04/2012 23:02, Ed W wrote:
>>On 16/04/2012 18:32, Rich Felker wrote:
>>>On Mon, Apr 16, 2012 at 05:57:47PM +0100, Ed W wrote:
>>>>Rich, disregarding posix for a moment, what does glibc do?  Options
>>>>are: canonname=NULL  or IP as string?
>>>If the AI_CANONNAME flag is not specified, the value of the
>>>ai_canonname field in the returned structure is unspecified; in this
>>>case it should not be filled in at all unless there's no cost to
>>>filling it (IIRC musl always fills it because filling it is free if
>>>done right).
>>>
>>>>At present uclibc is returning the reverse dns lookup or textual IP
>>>>format.  It should be trivial for me to supply a patch to make this
>>>>whatever we want - can someone define what we want? (Posix or
>>>>emulate some other wierdness?)
>>>Per POSIX:
>>>
>>>     If nodename is not null, and if requested by the AI_CANONNAME
>>>     flag, the ai_canonname field of the first returned addrinfo
>>>     structure shall point to a null-terminated string containing the
>>>     canonical name corresponding to the input nodename; if the
>>>     canonical name is not available, then ai_canonname shall refer to
>>>     the nodename argument or a string with the same contents. The
>>>     contents of the ai_flags field of the returned structures are
>>>     undefined.
>>>
>>>My reading is that in the numeric case, since there is no canonical
>>>name, the text about storing a pointer to the input nodename, or a
>>>duplicate of the same, applies.
>>>
>>
>>OK, please see attached version 2 of my patch which I believe
>>implements this satisfactorarily
>>
>>As before the motivation is to avoid making DNS queries when
>>calling getaddrinfo with a numerical IP address.  Performance
>>improves dramatically in such situations
>>
>>Grateful if others with more experience will verify and commit
>
>Sorry, typo - s/NUMERICSERV/NUMERICHOST/
>
>Patch re-attached v3
>
>Ed W

>Posix says that canonname should use the text representation of an IP address
>when a numerical nodename given
>See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html
>
>Signed-off-by: Ed Wildgoose <lists at wildgooses.com>

Applied, thanks!


More information about the uClibc mailing list