1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
8 * \brief Initialize global things
23 #include <gnutls/gnutls.h>
31 #include <libxml/parser.h>
35 #include <libxslt/xslt.h>
39 #include <libexslt/exslt.h>
42 static int yaz_init_flag = 0;
44 static pthread_mutex_t yaz_init_mutex = PTHREAD_MUTEX_INITIALIZER;
47 extern void yaz_log_init_globals(void);
50 GCRY_THREAD_OPTION_PTHREAD_IMPL;
53 void yaz_init_globals(void)
58 pthread_mutex_lock(&yaz_init_mutex);
62 yaz_log_init_globals();
64 /* POSIX threads locking. In case gnutls_global_init do not override */
65 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
71 /* most likely, GnuTLS has already initialized libgcrypt */
72 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
74 gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0);
86 yaz_init_flag = 1; /* must be last, before unlocking */
89 pthread_mutex_unlock(&yaz_init_mutex);
93 void yaz_deinit_globals(void)
98 pthread_mutex_lock(&yaz_init_mutex);
102 yaz_log_init_file(0);
104 gnutls_global_deinit();
107 xsltCleanupGlobals();
114 #if YAZ_POSIX_THREADS
115 pthread_mutex_unlock(&yaz_init_mutex);
122 * c-file-style: "Stroustrup"
123 * indent-tabs-mode: nil
125 * vim: shiftwidth=4 tabstop=8 expandtab