[FFmpeg-cvslog] network: Always use our version of gai_strerror on windows

Martin Storsjö git at videolan.org
Mon Jul 16 20:51:10 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Jun 25 12:50:13 2012 +0300| [9e4b04f8b9bce79adeb6f7784619a93d5682d509] | committer: Martin Storsjö

network: Always use our version of gai_strerror on windows

Even if linking directly to getaddrinfo, use our version of
gai_strerror instead of the system's version. Microsoft explicitly
documents that their version of gai_strerror is thread-unsafe.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e4b04f8b9bce79adeb6f7784619a93d5682d509
---

 libavformat/network.h    |    4 +++-
 libavformat/os_support.c |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/network.h b/libavformat/network.h
index 271f745..19c5a92 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -177,10 +177,12 @@ void ff_freeaddrinfo(struct addrinfo *res);
 int ff_getnameinfo(const struct sockaddr *sa, int salen,
                    char *host, int hostlen,
                    char *serv, int servlen, int flags);
-const char *ff_gai_strerror(int ecode);
 #define getaddrinfo ff_getaddrinfo
 #define freeaddrinfo ff_freeaddrinfo
 #define getnameinfo ff_getnameinfo
+#endif
+#if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H
+const char *ff_gai_strerror(int ecode);
 #undef gai_strerror
 #define gai_strerror ff_gai_strerror
 #endif
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 76204e0..9992a63 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -239,7 +239,9 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
 
     return 0;
 }
+#endif /* !HAVE_GETADDRINFO */
 
+#if !HAVE_GETADDRINFO || HAVE_WINSOCK2_H
 const char *ff_gai_strerror(int ecode)
 {
     switch(ecode) {
@@ -258,7 +260,7 @@ const char *ff_gai_strerror(int ecode)
 
     return "Unknown error";
 }
-#endif
+#endif /* !HAVE_GETADDRINFO || HAVE_WINSOCK2_H */
 
 int ff_socket_nonblock(int socket, int enable)
 {



More information about the ffmpeg-cvslog mailing list