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

Re: Thread safety question

"Kurt D. Zeilenga" wrote:
> At 07:17 AM 2002-01-02, Don Zick wrote:
> >Is it safe for one application thread to call ldap_search() and another
> >to call ldap_result()?
> When using -lldap_r, an application can use each LDAP session
> handle in one thread at a time.  Normally, the application
> ensures this by restricting operations upon a handle to one
> thread, however the application is free to use other means
> to serialize calls upon a handle.
> Also note that calls which don't take a session handle also
> need to be serialized...

Interesting topic.

I'm currently maintaining python-ldap which is mainly a C wrapper
module around the OpenLDAP 2 libs. The LDAP session handle once
gathered is solely used within a LDAPObject instance.

At the moment I'm serializing *all* calls into libldap with a single
global lock (global functions like ldap_initialize() and LDAP
operations implemented as methods of Python class LDAPObject, e.g.
ldap_search()) which is quite unsatisfying in some situations.

Kurt, if I understood your message above correctly with -lldap_r it
is only necessary to serialize the use of each LDAP session handle
with a separate lock.

How about calls into global functions ldap_initialize(),
ldap_set_option() etc. Can I use separate locks for all of these
functions or do they interfere with each other?

Ciao, Michael.