[gnutls-devel] eliminating gnutls_global_init
nmav at gnutls.org
Sat Nov 30 09:54:08 CET 2013
On Fri, 2013-11-29 at 16:06 -0800, Andy Lutomirski wrote:
> On Fri, Nov 29, 2013 at 4:01 PM, Nikos Mavrogiannopoulos
> <nmav at gnutls.org> wrote:
> > Hello,
> > I'm considering moving parts of gnutls_global_init to a library
> > constructor. That would mean that in ELF systems and systems that
> > support constructors, it would be possible to use gnutls without calling
> > gnutls_global_init().
> In theory, a different library could create a thread in a constructor
> or try to use GnuTLS from a constructor, causing problems. (This
> might be unlikely.)
One cannot use gnutls from a constructor unless he calls
gnutls_global_init() which has a reference counter, so there would be no
issue there, since constructors are run serialized.
> I think that automatically initializing this stuff on the first call
> into GnuTLS would be ideal.
The question is on the first call to what? There are so many functions
this is hardly an option. Even if it would be an option, each call would
have to check the global initialization mutex, which would slow things
down when many threads are used.
As it is now a constructor solves many issues, and the only cost I see
is a different API when static linking which requires the
More information about the Gnutls-devel