Re: ldap_str2dn() and ldap_dn2str() reentrant?
Howard Chu <[email protected]> Sun, 16 May 2010 10:12:03 -0700
| Newsgroups | gmane.network.openldap.general |
|---|---|
| Message-ID | <[email protected]> |
Michael Str=F6der wrote: > Michael Str=F6der wrote: >> Routinely in the C module part of python-ldap all calls to libldap fun= ctions >> are wrapped by a thread lock. But I wonder whether that's really neces= sary for >> all of them, especially regarding ldap_str2dn() and ldap_dn2str(). > > Mainly for python-ldap this question boils down to whether ldap_bv2dn_x= () and > ldap_bv2rdn_x() are re-entrant. Glancing over these it seems they are > re-entrant. But it would be nice if one of the OpenLDAP developers coul= d > confirm that. *You're* an OpenLDAP developer... ;) Yes, these functions are re-entrant. I would say most of libldap's functi= ons=20 *don't* need any locking. The only really important thing is to call=20 ldap_init() once in the main program before any threads start, to make su= re=20 that all of the global library options get parsed before threading occurs= .=20 Beyond that, if you make sure that only one thread can use an LDAP handle= at a=20 time, there's no really re-entrancy issues to speak of. Of course, there are no guarantees on underlying libraries that libldap u= ses,=20 like SASL, OpenSSL, etc... If you need those features in a threaded progr= am,=20 you need to use libldap_r because libldap doesn't do any thread initializ= ation=20 for those other libraries. --=20 -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/