Code

network.c: call gcry_check_version() as required by library.
authorChris Lundquist <chris.lundquist@bluebox.net>
Fri, 12 Oct 2012 10:15:13 +0000 (03:15 -0700)
committerFlorian Forster <octo@collectd.org>
Sat, 20 Oct 2012 07:28:35 +0000 (09:28 +0200)
Signed-off-by: Florian Forster <octo@collectd.org>
src/network.c

index 570b9d4f552cf4757a0b240bebbffcada7dd8a9e..d6e0dc0174c359af26a1ad6b576a2a4c28743ccd 100644 (file)
@@ -3348,9 +3348,17 @@ static int network_init (void)
        have_init = true;
 
 #if HAVE_LIBGCRYPT
-       gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-       gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
-       gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+    /* http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html
+     * Because you can't know in a library whether another library has
+     * already initialized the library
+     */
+    if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
+    {
+        gcry_check_version(NULL); /* before calling any other functions */
+        gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+        gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
+        gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+    }
 #endif
 
        if (network_config_stats != 0)