On Tue, Sep 9, 2008 at 8:37 PM, Nelson B Bolyard <[EMAIL PROTECTED]> wrote:
> Rob Crittenden wrote, On 2008-09-09 20:18:
>
>> Does this mean than an explicit PR_Init() is not required?
>
> Whenever you call a public PR_ function, if NSPR is not already initialized,
> it will get initialized by that first call.  (*)
>
> However, NSPR initialization should only be done on one thread.  It's bad
> if multiple threads call NSPR Functions that all try to initialize NSPR
> simultaneously.
>
> PR_Init exists to provide a way to initialize NSPR at a point in the program
> when the programmer is sure that no other thread can possibly be using NSPR.

You're right.  So PR_Init still has some value.  The best solution
to this problem is for libnspr4.so to call NSPR initialization at
shared library initialization time (the so-called _init routine).
We should do this on all POSIX systems.  We may not be
able to do this on Windows because Windows imposes
severe constraints on what functions DllMain may call.

> Note: (*) I'm not sure this is correct for 100% of the public NSPR PR_
> functions, but I believe it is true for the vast majority.  It may be that
> some functions, such as those that operate on open PRFileDescriptors, may
> not initialize NSPR, because they reasonably assume that the functions
> that returned those newly opened PRFileDescriptors would have initialized
> NSPR.  This is speculation.  Perhaps Wan-Teh will make an authoritative
> statement about this.

Yes.

Wan-Teh
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to