From: Chris Lundquist Date: Fri, 12 Oct 2012 10:15:13 +0000 (-0700) Subject: network.c: call gcry_check_version() as required by library. X-Git-Tag: collectd-5.0.5~1^2~10 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=80d8e6744a2736e25ac2d991b51ac2a6710b0994;p=collectd.git network.c: call gcry_check_version() as required by library. Signed-off-by: Florian Forster --- diff --git a/src/network.c b/src/network.c index 570b9d4f..d6e0dc01 100644 --- a/src/network.c +++ b/src/network.c @@ -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)