X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Finit_globals.c;h=6bd03fb0db02c6a9d99224454f4ec356268e1771;hp=81301e2db2aba5d3307f5f61e83c65962aaefc4d;hb=8cb8947e3a7bff4dbf8f124871cb4905df1adce7;hpb=f516f94ad6cc3f11275e9dec04c9c523591b7a23 diff --git a/src/init_globals.c b/src/init_globals.c index 81301e2..6bd03fb 100644 --- a/src/init_globals.c +++ b/src/init_globals.c @@ -15,6 +15,7 @@ #if YAZ_POSIX_THREADS #include #endif +#include #if HAVE_GNUTLS_H #include @@ -24,27 +25,53 @@ #include #endif +#if YAZ_HAVE_EXSLT +#include +#endif + static int yaz_init_flag = 0; +#if YAZ_POSIX_THREADS +static pthread_mutex_t yaz_init_mutex = PTHREAD_MUTEX_INITIALIZER; +#endif extern void yaz_log_init_globals(void); +#if HAVE_GCRYPT_H +GCRY_THREAD_OPTION_PTHREAD_IMPL; +#endif + void yaz_init_globals(void) { + if (yaz_init_flag) + return; +#if YAZ_POSIX_THREADS + pthread_mutex_lock(&yaz_init_mutex); +#endif if (!yaz_init_flag) { - yaz_init_flag = 1; yaz_log_init_globals(); +#if HAVE_GCRYPT_H + /* POSIX threads locking. In case gnutls_global_init do not override */ + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif #if HAVE_GNUTLS_H gnutls_global_init(); #endif #if HAVE_GCRYPT_H - /* most likely, GnuTLS has initialized libgcrypt */ + /* most likely, GnuTLS has already initialized libgcrypt */ if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) { gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } #endif +#if YAZ_HAVE_EXSLT + exsltRegisterAll(); +#endif + yaz_init_flag = 1; /* must be last, before unlocking */ } +#if YAZ_POSIX_THREADS + pthread_mutex_unlock(&yaz_init_mutex); +#endif } /*