[FFmpeg-devel] [PATCH] ffserver: stop using the deprecated resolve_host()
Måns Rullgård
mans
Mon Mar 8 16:28:16 CET 2010
Martin Storsj? <martin at martin.st> writes:
> On Mon, 8 Mar 2010, Mans Rullgard wrote:
>
>> This replaces resolve_host() usage in ffserver with a wrapper
>> for getaddrinfo returning the first IPv4 address, if any.
>>
>> Ultimately, ffserver should be made to work with IPv6 addresses,
>> but that change is much more involved.
>> ---
>> ffserver.c | 32 +++++++++++++++++++++++++++-----
>> 1 files changed, 27 insertions(+), 5 deletions(-)
>>
>> diff --git a/ffserver.c b/ffserver.c
>> index e6b8034..1d5c2d8 100644
>> --- a/ffserver.c
>> +++ b/ffserver.c
>> @@ -312,6 +312,28 @@ static AVLFG random_state;
>>
>> static FILE *logfile = NULL;
>>
>> +static int get_inet_addr(struct in_addr *sin_addr, const char *hostname)
>> +{
>> + struct addrinfo *addr_list, *addr;
>> + int err;
>> +
>> + err = getaddrinfo(hostname, NULL, NULL, &addr_list);
>> + if (err)
>> + return err;
>> +
>> + for (addr = addr_list; addr; addr = addr->ai_next)
>> + if (addr->ai_family == AF_INET)
>> + break;
>> +
>> + if (addr)
>> + *sin_addr = ((struct sockaddr_in *)addr->ai_addr)->sin_addr;
>> + else
>> + err = -1;
>> +
>> + freeaddrinfo(addr_list);
>> + return err;
>> +}
>> +
>
> Generally ok for me, although I'm a bit sceptical.
>
> But, this is more or less a simplified reimplementation of resolve_host...
> (resolve_host could be simplified nowadays when getaddrinfo always is
> available, note to self/Ronald.) As long as the ffserver code isn't
> updated to use getaddrinfo intelligently, moving the deprecated wrapper
> function from libavformat to ffserver doesn't really gain all that much,
> except for masking the notice that the code should be overhauled.
The point is to stop using a deprecated function which doesn't even
have a prototype visible here (it's under ifdef HAVE_AV_CONFIG_H).
Any solution reaching this goal is fine by me.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list