Always initialize libgcrypt for POSIX threads YAZ-751
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 13 Mar 2014 13:37:25 +0000 (13:37 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 13 Mar 2014 13:37:25 +0000 (13:37 +0000)
gnutls_global_init, we now know, in some systems, do not properly
initialize libgcrypt for POSIX threads.

src/init_globals.c

index 79845f4..abb918b 100644 (file)
@@ -50,6 +50,10 @@ void yaz_init_globals(void)
     if (!yaz_init_flag)
     {
         yaz_log_init_globals();
+#if HAVE_GCRYPT_H
+        /* POSIX threads locking. gnutls_global_init will not override */
+        gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+#endif
 #if HAVE_GNUTLS_H
         gnutls_global_init();
 #endif
@@ -57,7 +61,6 @@ 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