[FFmpeg-devel] [PATCH/RFC] Prefer getaddrinfo over gethostbyname

Måns Rullgård mans
Fri Jan 8 02:41:37 CET 2010


Replied to the wrong mail first...

Martin Storsj? <martin at martin.st> writes:

> From 2bc36d4ec7c9003d4aaa8da82ad92c664da31c9d Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Sat, 2 Jan 2010 23:44:42 +0200
> Subject: [PATCH 01/13] Check for the getaddrinfo function
>
> ---
>  configure |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 275fa88..1cdf478 100755
> --- a/configure
> +++ b/configure
> @@ -954,6 +954,7 @@ HAVE_LIST="
>      fast_cmov
>      fast_unaligned
>      fork
> +    getaddrinfo
>      gethrtime
>      GetProcessTimes
>      getrusage
> @@ -2309,6 +2310,7 @@ fi
>  check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
>  
>  check_func  fork
> +check_func  getaddrinfo $network_extralibs
>  check_func  gethrtime
>  check_func  getrusage
>  check_func  inet_aton $network_extralibs

Still OK.

> From a8a60ae9a5118eaeb2e9ecd5da0f5303d17b8928 Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Mon, 4 Jan 2010 00:19:24 +0200
> Subject: [PATCH 03/13] Make check_type handle type names containing spaces
>
> ---
>  configure |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 1cdf478..3627112 100755
> --- a/configure
> +++ b/configure
> @@ -735,6 +735,7 @@ check_type(){
>      log check_type "$@"
>      headers=$1
>      type=$2
> +    type_quoted=$(echo "$type" | sed 's/ /_/g')
>      shift 2
>      disable $type
>      incs=""
> @@ -742,7 +743,7 @@ check_type(){
>          incs="$incs
>  #include <$hdr>"
>      done
> -    check_cc "$@" <<EOF && enable $type
> +    check_cc "$@" <<EOF && enable $type_quoted
>  $incs
>  $type v;
>  EOF

Use enable_safe/disable_safe.

> From 9cf219ab7ad15eb6863c8e9246171186e500c39c Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Mon, 4 Jan 2010 00:07:59 +0200
> Subject: [PATCH 04/13] Check for the addrinfo struct, needed for using getaddrinfo
>
> ---
>  configure |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 3627112..5c0b6dc 100755
> --- a/configure
> +++ b/configure
> @@ -986,6 +986,7 @@ HAVE_LIST="
>      socklen_t
>      soundcard_h
>      poll_h
> +    struct_addrinfo
>      sys_mman_h
>      sys_resource_h
>      sys_select_h
> @@ -2445,6 +2446,7 @@ texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
>  
>  if enabled network; then
>      check_type "sys/types.h sys/socket.h" socklen_t
> +    check_type netdb.h "struct addrinfo"
>      # Prefer arpa/inet.h over winsock2
>      if check_header arpa/inet.h ; then
>          check_func closesocket
> @@ -2454,6 +2456,7 @@ if enabled network; then
>          { check_func_headers winsock2.h closesocket -lws2_32 && \
>              network_extralibs="-lws2_32"; }
>          check_type ws2tcpip.h socklen_t
> +        check_type ws2tcpip.h "struct addrinfo"
>      else
>          disable network
>      fi

OK

> From 8783c7162749e85da5425f9d458b51246644ad59 Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Wed, 6 Jan 2010 14:48:55 +0100
> Subject: [PATCH 10/13] Don't check for getaddrinfo/getnameinfo in the ipv6 check
>
> We already provide fallbacks for them, so they can be relied upon.
> ---
>  configure |    2 --
>  1 files changed, 0 insertions(+), 2 deletions(-)
>
> diff --git a/configure b/configure
> index 9fe0bea..8839069 100755
> --- a/configure
> +++ b/configure
> @@ -2473,8 +2473,6 @@ enabled_all network ipv6 && check_ld <<EOF || disable ipv6
>  int main(void) {
>      struct sockaddr_storage saddr;
>      struct ipv6_mreq mreq6;
> -    getaddrinfo(0,0,0,0);
> -    getnameinfo(0,0,0,0,0,0,0);
>      IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
>  }
>  EOF
>
> From a43471cff029e2c9fb17a3bb259c56e95b778740 Mon Sep 17 00:00:00 2001
> From: Martin Storsjo <martin at martin.st>
> Date: Wed, 6 Jan 2010 14:52:56 +0100
> Subject: [PATCH 11/13] When doing the IPv6 check, check in mingw specific headers, too
>
> ---
>  configure |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 8839069..ccaf9b7 100755
> --- a/configure
> +++ b/configure
> @@ -2465,11 +2465,15 @@ if enabled network; then
>      fi
>  fi
>  
> -enabled_all network ipv6 && check_ld <<EOF || disable ipv6
> +enabled_all network ipv6 && check_ld $network_extralibs <<EOF || disable ipv6
> +#ifdef __MINGW32__
> +#include <ws2tcpip.h>
> +#else
>  #include <sys/types.h>
>  #include <sys/socket.h>
>  #include <netinet/in.h>
>  #include <netdb.h>
> +#endif
>  int main(void) {
>      struct sockaddr_storage saddr;
>      struct ipv6_mreq mreq6;

What is the purpose of that check?  Whatever it's looking for can
probably be checked individually with the various standard tests.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list