@@ -84,6 +84,11 @@ Local naming conventions:
8484*/
8585
8686#ifdef __APPLE__
87+ #include <AvailabilityMacros.h>
88+ /* for getaddrinfo thread safety test on old versions of OS X */
89+ #ifndef MAC_OS_X_VERSION_10_5
90+ #define MAC_OS_X_VERSION_10_5 1050
91+ #endif
8792 /*
8893 * inet_aton is not available on OSX 10.3, yet we want to use a binary
8994 * that was build on 10.4 or later to work on that release, weak linking
@@ -184,8 +189,19 @@ if_indextoname(index) -- return the corresponding interface name\n\
184189#include <sys/param.h>
185190#endif
186191/* On systems on which getaddrinfo() is believed to not be thread-safe,
187- (this includes the getaddrinfo emulation) protect access with a lock. */
188- #if defined(WITH_THREAD ) && (defined(__APPLE__ ) || \
192+ (this includes the getaddrinfo emulation) protect access with a lock.
193+
194+ getaddrinfo is thread-safe on Mac OS X 10.5 and later. Originally it was
195+ a mix of code including an unsafe implementation from an old BSD's
196+ libresolv. In 10.5 Apple reimplemented it as a safe IPC call to the
197+ mDNSResponder process. 10.5 is the first be UNIX '03 certified, which
198+ includes the requirement that getaddrinfo be thread-safe.
199+
200+ See issue #25924 for details.
201+ */
202+ #if defined(WITH_THREAD ) && ( \
203+ (defined(__APPLE__ ) && \
204+ MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 ) || \
189205 (defined(__FreeBSD__ ) && __FreeBSD_version + 0 < 503000 ) || \
190206 defined(__OpenBSD__ ) || defined(__NetBSD__ ) || \
191207 !defined(HAVE_GETADDRINFO ))
0 commit comments