diff -r c080ef5989f7 Modules/socketmodule.c --- a/Modules/socketmodule.c Fri Jan 29 19:09:41 2016 -0600 +++ b/Modules/socketmodule.c Tue Feb 02 16:59:44 2016 -0500 @@ -84,6 +84,8 @@ */ #ifdef __APPLE__ +/* To use MAC_OS_X_VERSION_10_5 */ +#include /* * inet_aton is not available on OSX 10.3, yet we want to use a binary * that was build on 10.4 or later to work on that release, weak linking @@ -184,8 +186,18 @@ #include #endif /* On systems on which getaddrinfo() is believed to not be thread-safe, - (this includes the getaddrinfo emulation) protect access with a lock. */ -#if defined(WITH_THREAD) && (defined(__APPLE__) || \ + (this includes the getaddrinfo emulation) protect access with a lock. + + getaddrinfo is thread-safe on Mac OS X 10.5 and later. Originally it was + a mix of code including an unsafe implementation from an old BSD's + libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the + mDNSResponder process. 10.5 is the first be UNIX '03 certified, which + includes the requirement that getaddrinfo be thread-safe. + + See issue #25924 for details. + */ +#if defined(WITH_THREAD) && ( \ + (defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)) || \ (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \ defined(__OpenBSD__) || defined(__NetBSD__) || \ !defined(HAVE_GETADDRINFO))