Hello everyone!

I managed to fix my problem. My app is multi-threaded and though I thought I was pretty clean in ensuring that I was only managing the ldap instance in one thread, I discovered that I was indeed calling ldap_unbind from a different thread.

I had a window of opportunity for the unbind to be called by another thread while in the midst of a call to ldap_search_ext from my main thread. Bad. So bad.

So now I'm extremely careful that all my ldap calls are within my single main thread. Now, my only exception to this is that my main thread starts and stops a temporary thread for the ldap_simple_bind call (I can't block in my main thread). But with the main thread being the owner, I'm pretty confident that I've got everything properly mutexed.

It was tricky to debug because I'm so nspr-ignorant (and I know even less about nss). But, all is well. I appreciate all of your responses.

Thanks,
- Matthew


Mark Smith wrote:

I am not sure, but some of the initialization and shutdown functions are probably only designed to be called once. I would also recommend calling them on the main (primordial) thread. So a more typical usage pattern would be:

in main at app startup time:
  ldapssl_advclientauth_init()

...
make LDAP calls using on any threads
...

when you program is exiting:
  ldapssl_shutdown();
  PR_Cleanup();

It probably makes sense to ask about your crash on the NSPR list. The LDAP C SDK is using NSPR somewhat indirectly through NSS when SSL is used.


_______________________________________________
dev-tech-ldap mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-ldap

Reply via email to