From: Adam Dickmeiss Date: Thu, 22 Oct 2015 14:31:26 +0000 (+0200) Subject: Cleanup de-init function YAZ-863 X-Git-Tag: v5.14.12~12 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=d438b90ac17fbae25ba2554dd76f4e156f420437;p=yaz-moved-to-github.git Cleanup de-init function YAZ-863 New function yaz_deinit_globals --- diff --git a/include/yaz/yconfig.h b/include/yaz/yconfig.h index ce0d44f..83f0b6c 100644 --- a/include/yaz/yconfig.h +++ b/include/yaz/yconfig.h @@ -59,6 +59,8 @@ YAZ_BEGIN_CDECL YAZ_EXPORT void yaz_init_globals(void); +YAZ_EXPORT void yaz_deinit_globals(void); + YAZ_END_CDECL #endif diff --git a/src/init_globals.c b/src/init_globals.c index 6bd03fb..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 @@ -64,6 +74,12 @@ void yaz_init_globals(void) 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 @@ -74,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 diff --git a/src/test.c b/src/test.c index 258517e..4e6b960 100644 --- a/src/test.c +++ b/src/test.c @@ -158,6 +158,7 @@ void yaz_check_term1(void) } if (test_fout) fclose(test_fout); + yaz_deinit_globals(); if (test_failed) exit(1); exit(0); diff --git a/test/test_icu.c b/test/test_icu.c index 5107693..e7fc1ef 100644 --- a/test/test_icu.c +++ b/test/test_icu.c @@ -984,10 +984,6 @@ int main(int argc, char **argv) check_norm(); u_cleanup(); -#if YAZ_HAVE_XML2 - xmlCleanupParser(); -#endif - #else /* YAZ_HAVE_ICU */ yaz_log(YLOG_LOG, "ICU unit tests omitted"); diff --git a/test/test_record_conv.c b/test/test_record_conv.c index fa65224..37cb520 100644 --- a/test/test_record_conv.c +++ b/test/test_record_conv.c @@ -626,10 +626,6 @@ int main(int argc, char **argv) tst_convert2(); tst_convert3(); tst_convert4(); - xsltCleanupGlobals(); -#endif -#if YAZ_HAVE_XML2 - xmlCleanupParser(); #endif YAZ_CHECK_TERM; }