Author: Steve Langasek OpenLDAP upstream conservatively assumes that certain resolver functions (getaddrinfo, getnameinfo, res_query, dn_expand) are not re-entrant; but we know that the glibc implementations of these functions are thread-safe, so we should bypass the use of this mutex. This fixes a locking problem when an application uses libldap and libnss-ldap is also used for hosts resolution. Closes Debian bug #340601. Not suitable for forwarding upstream; might be made suitable by adding a configure-time check for glibc and disabling the mutex only on known thread-safe implementations. Index: trunk/libraries/libldap/os-ip.c =================================================================== --- trunk.orig/libraries/libldap/os-ip.c +++ trunk/libraries/libldap/os-ip.c @@ -477,17 +477,8 @@ hints.ai_socktype = socktype; snprintf(serv, sizeof serv, "%d", port ); -#ifdef LDAP_R_COMPILE - /* most getaddrinfo(3) use non-threadsafe resolver libraries */ - ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex); -#endif - err = getaddrinfo( host, serv, &hints, &res ); -#ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex); -#endif - if ( err != 0 ) { osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0); Index: trunk/libraries/libldap/util-int.c =================================================================== --- trunk.orig/libraries/libldap/util-int.c +++ trunk/libraries/libldap/util-int.c @@ -224,13 +224,7 @@ int rc; #if defined( HAVE_GETNAMEINFO ) -#if defined( LDAP_R_COMPILE ) - ldap_pvt_thread_mutex_lock( &ldap_int_resolv_mutex ); -#endif rc = getnameinfo( sa, len, name, namelen, NULL, 0, 0 ); -#if defined( LDAP_R_COMPILE ) - ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex ); -#endif if ( rc ) *err = (char *)AC_GAI_STRERROR( rc ); return rc;