X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Finit_globals.c;h=786cb9c3425b74874ac46d8be11b2d3ad9228716;hb=eec02e3b60802638aa3a105f3037814cf32af3b6;hp=79845f43c499419f9479d77af68659d5cd82f8dd;hpb=7b35dc1bb4add8c5db287eecdf57bb872751eea3;p=yaz-moved-to-github.git diff --git a/src/init_globals.c b/src/init_globals.c index 79845f4..786cb9c 100644 --- a/src/init_globals.c +++ b/src/init_globals.c @@ -12,6 +12,8 @@ #include #endif +#include + #if YAZ_POSIX_THREADS #include #endif @@ -25,6 +27,14 @@ #include #endif +#if YAZ_HAVE_XML2 +#include +#endif + +#if YAZ_HAVE_XSLT +#include +#endif + #if YAZ_HAVE_EXSLT #include #endif @@ -50,6 +60,10 @@ void yaz_init_globals(void) if (!yaz_init_flag) { 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 @@ -57,10 +71,15 @@ void yaz_init_globals(void) /* most likely, GnuTLS has already initialized libgcrypt */ if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) { - gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0); } #endif +#if YAZ_HAVE_XML2 + xmlInitParser(); +#endif +#if YAZ_HAVE_XSLT + xsltInit(); +#endif #if YAZ_HAVE_EXSLT exsltRegisterAll(); #endif @@ -71,6 +90,31 @@ void yaz_init_globals(void) #endif } +void yaz_deinit_globals(void) +{ + if (!yaz_init_flag) + return; +#if YAZ_POSIX_THREADS + pthread_mutex_lock(&yaz_init_mutex); +#endif + if (yaz_init_flag) + { +#if HAVE_GNUTLS_H + gnutls_global_deinit(); +#endif +#if YAZ_HAVE_XSLT + xsltCleanupGlobals(); +#endif +#if YAZ_HAVE_XML2 + xmlCleanupParser(); +#endif + yaz_init_flag = 0; + } +#if YAZ_POSIX_THREADS + pthread_mutex_unlock(&yaz_init_mutex); +#endif +} + /* * Local variables: * c-basic-offset: 4