C-SDK Question - Multithreaded Client

"Parag" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.directory
Organization http://groups.google.com
Message-ID <[email protected]>
[I posted this earlier but it went into moderation since I wasn't
subscribed - reposting after waiting a day]

I am a little confused on when to use the thread functions when using
LDAP C-SDK (ldap_thread_fns). Mozilla documentation says if I need to
share a LDAP structure among different threads I got to use the thread
functions.

What does "Share" mean in this context - share as in used by different
threads concurrently or shared as in say a connection pool type of
scenario where only one thread uses the LDAP* at one time but any
thread can use any LDAP* at different times, Or does it imply both/
any?

I have some legacy code which uses the C-SDK which currently is
crashing in the threading functions. The code has a connection pool
implementation which uses one separate LDAP* per connection. At any
point of time only one thread uses a given LDAP* but as the
connections are handed over randomly to calling threads, a thread X
may use connection A at one time and after it is done, some other
thread Y may come in and use the same connection A, exclusively for
that time.

Are the threading functions required in this scenario? I ask because I
suspect that once a thread uses a LDAP* it may leave some state behind
that may be problematic when used with other thread and thus I would
end up requiring to use the thread functions.

I also think that I may maintain a static mapping between thread-
>LDAP* and always use the same LDAP* for the particular thread but
since caller threads are randomly created and destroyed this approach
doesn't sound promising.

I seem to recall that the prldap functions automatically take care of
thread safety? Would switching to prldap from plain ldap_* functions
be the wise thing to do here?

Thanks in advance for any clues!

Parag
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.