Emmanuel Dreyfus wrote:
Hello
I have thread-safety problems with libldap_r. My program uses libcurl to access a LDAP URL. When I attempt to fetch LDAP URL from multiple threads at once, I crash.
I suspect there could be thread-safety issues with libldap_r. for instance, a nm shows it references gethostbyname, and not gethostname_r. Does it has any chance to be thread-safe if it uses gethostbyname?
The configure script checks for reentrant interfaces like gethostbyname_r. If it didn't find them, then libldap_r will use mutexes to protect the non-reentrant functions. Note that gethostname is not the same as gethostbyname.
If your version of libldap_r is not using the re-entrant APIs then something went wrong during configure to prevent it from finding those APIs. You should check your config.log...
That aside, libldap_r is (intentionally) undocumented; you use it at your own risk. We've made it reliable enough for slapd's purposes. If you're using it in any way differently from how slapd uses it, you're on your own.