Re: Crash in NSPR from within LDAP C-SDK - Bad MDOverlapped struct from GetQueuedCompletionStatus?

Mark Smith <[email protected]> Fri, 12 Feb 2010 08:50:53 -0500
Newsgroups gmane.comp.mozilla.devel.directory
Message-ID <[email protected]>
Matthew M. DeLoera wrote:
> Hello,
> 
> In investigating further, I see the calls in ldapssl_basic_init to 
> PR_Init and PR_SetConcurrency. explaining the extra NSPR threads when 
> running in SSL mode. From further reading about NSPR, I'm starting to 
> get the impression that there's a "proper" usage model for the LDAP SDK. 
> I'd never noticed anything about this in the docs, but if any of you can 
> point me to a relevant section, I'd appreciate it.
> 
> Can any of you confirm whether the following usage is ok:
> 
> MAIN APP START
>     - ldapssl_advclientauth_init()
> 
> START THREAD X
>     - either call ldapssl_init or ldap_init
>     - ldap_simple_bind
>     - exit thread X
> 
> START THREAD Y
>     - execute LDAP queries
>     - exit thread Y
> 
> START THREAD Z
>     - ldap_unbind
>     - ldapssl_shutdown (only if I was using SSL)
> 
> MAIN APP EXIT
>     - do nothing

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.

-- 
Mark Smith
Pearl Crescent
http://pearlcrescent.com/