[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Is the openldap libldap library thread safe?

On Fri, 2006-06-23 at 13:35 -0400, Aaron Richton wrote:
> libldap_r is the version of libldap compiled with the reentrant #defines
> (LDAP_R_COMPILE or something like that? I forget.) As far as I know, the
> API is identical, although there's a chance a couple *_thread_* might be
> exposed. I believe the define makes libldap use things like
> gethostbyname_r and other things that you'd want in a multithreaded
> application.

As far as I know, libldap is thread safe in the sense that multiple
threads can use separate LDAP* handles without running into concurrency
issues; except for library initialization, all accesses to common data
(i.e. global variables) is read-only.

libldap_r is a (private, i.e. it doesn't get installed) version of
libldap which is internally used by programs in the OpenLDAP suite that
need to __share__ LDAP* handles between threads; as a consequence,
concurrent activity related to LDAP* handles requires mutex protection
and so.

The API is identical; there is no provision for using libldap_r outside
of the project build tree.  To do that, one needs to arrange for
libldap_r installation.

In general, clients do not need libldap_r unless a single LDAP* handle
needs be shared among threads.  Well-behaved clients shouldn't need
that, while a server (e.g. a proxy) could (see slapd's back-ldap as an


Ing. Pierangelo Masarati
Responsabile Open Solution
OpenLDAP Core Team

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
Office:   +39.02.23998309          
Mobile:   +39.333.4963172
Email:    pierangelo.masarati@sys-net.it