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
21 #include <gnutls/gnutls.h>
29 #include <libexslt/exslt.h>
32 static int yaz_init_flag = 0;
34 static pthread_mutex_t yaz_init_mutex = PTHREAD_MUTEX_INITIALIZER;
37 extern void yaz_log_init_globals(void);
40 GCRY_THREAD_OPTION_PTHREAD_IMPL;
43 void yaz_init_globals(void)
48 pthread_mutex_lock(&yaz_init_mutex);
52 yaz_log_init_globals();
54 /* POSIX threads locking. In case gnutls_global_init do not override */
55 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
61 /* most likely, GnuTLS has already initialized libgcrypt */
62 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
64 gcry_control(GCRYCTL_INITIALIZATION_FINISHED, NULL, 0);
70 yaz_init_flag = 1; /* must be last, before unlocking */
73 pthread_mutex_unlock(&yaz_init_mutex);
80 * c-file-style: "Stroustrup"
81 * indent-tabs-mode: nil
83 * vim: shiftwidth=4 tabstop=8 expandtab