[gnutls-devel] [TLS] multiple clients in one process (was: Re: Deployment ... Re: This working group has failed)

Nikos Mavrogiannopoulos nmav at gnutls.org
Sat Nov 30 10:03:55 CET 2013

On Fri, 2013-11-29 at 15:46 -0800, Andy Lutomirski wrote:

> > I don't quite understand by what you mean by synchronize. They don't
> > need to synchronize, they just need to initialize the library at an
> > early state.
> >
> >> Any self-respecting pthreads implementation should implement
> >> PTHREAD_MUTEX_INITIALIZER in such a way that it constant-initializes
> >> its data, making it completely safe.  An even better solution would be
> >> to use pthread_once.
> >
> > Unfortuntely that only works with pthreads. What about systems that
> > don't have static initializers for locks? Unfortunately we need a
> > consistent API for all the supported systems.
> Windows has an InitOnceInitialize, etc mechanism (on Vista and higher).
> In any case, getting this right on pthreads systems would be a major
> improvement over getting it wrong everywhere.

Right or wrong is in the eye of the beholder. A documented behavior is a
documented behavior (rather than right or wrong), and calling
gnutls_global_init() on each and every thread is not only unsafe but a
waste of resources.

Indeed, I can fix the unsafe part with static initializers, and I'll try
to, but that will not fix the waste of resources.


More information about the Gnutls-devel mailing list