[FFmpeg-devel] [PATCH] Use getaddrinfo instead of gethostbyname, if available

Ronald S. Bultje rsbultje
Fri Jan 1 19:43:20 CET 2010

Hi Martin,

On Fri, Jan 1, 2010 at 8:59 AM, Martin Storsj? <martin at martin.st> wrote:
> On Fri, 1 Jan 2010, Martin Storsj? wrote:
>> The attached patch makes resolve_host in libavformat use getaddrinfo
>> instead of gethostbyname, if getaddrinfo is available. gethostbyname isn't
>> necessarily thread safe (e.g. it isn't on glibc/linux, but on mac os x and
>> windows it is).
> ... and here's the patch, too...

I think I looked into using getaddrinfo() in the past. If memory
serves me right, what people wanted was that we'd drop any other API
alltogether, and sort of provide a fallback wrapper in libossupport if
getaddrinfo() & co are missing.

The advantage of that approach would be that in many places, we can
drop resolve_host alltogether. the inet_aton() before gethostbyname()
isn't needed with getaddrinfo(), it does that implicitely. The added
advantage of using *only* getaddrinfo() is also that we don't have to
worry about where the data is located in struct sockaddr_inX (think of
the size/offset diffs between in4/in6), and thus that adding support
for IPv6 would be very easy (which we indeed do not support right
now). Lastly, it means we can drop resolve_host() because
getaddrinfo() does all it does, and better.

(I, for one, would favour dropping resolve_host() altogether and using
getaddrinfo() or a fallback implementation using resolve_host()'s
stuff internally in libossupport() instead.)


More information about the ffmpeg-devel mailing list