[FFmpeg-devel] [PATCH] ffserver: stop using the deprecated resolve_host()

Martin Storsjö martin
Mon Mar 8 16:22:36 CET 2010


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.

So I'd say there isn't all that much point in this; if nobody wants to 
step up and modernize ffserver in that aspect, perhaps the deprecation 
from resolve_host should be removed to avoid all the redundant warnings? 
That has the same effect as this, shutting up the warnings, with less 
changed LOC.

Baptiste, Ronald?

// Martin



More information about the ffmpeg-devel mailing list