[gnutls-dev] Another solution

Simon Josefsson jas at extundo.com
Mon Dec 26 19:24:33 CET 2005

Here is another solution for removing the global variables without
changing any APIs [1]: replace all uses of the global variable with a
function call to a function that generate a local copy of the ASN.1
structures.  This will be slower, but would work.

However, gnutls_global_init() will not become thread safe by this
(because libgcrypt is used) but all the global variables in GnuTLS
would then be removed.

Thus, the above proposal to get rid of all global variables would not
solve your problem with thread safety anyway, so I propose we wait
with this idea until libgcrypt is thread safe or we support
alternatives to libgcrypt.

I again wish to stress that I believe this is a insignificant problem.
Simply have all libraries using GnuTLS call gnutls_global_init() in a
thread-unsafe initialization function, ultimately mutex synchronized
by the application.

[1] Changing APIs is really bad, that is why I'm having trouble with
your proposed approach.

More information about the Gnutls-devel mailing list