X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnetwork.c;h=3f0c6fa1a08858def27ffd167362475faf0fcbc8;hb=3427c2e266c04d67848bda913caa730a395c7295;hp=3cf222744262796d4ce964cf3c76d4c690202d49;hpb=a60550f0b85d413957654546a87f00a95e59a26c;p=collectd.git diff --git a/src/network.c b/src/network.c index 3cf22274..3f0c6fa1 100644 --- a/src/network.c +++ b/src/network.c @@ -66,6 +66,11 @@ */ # pragma GCC diagnostic ignored "-Wdeprecated-declarations" # endif +/* FreeBSD's copy of libgcrypt extends the existing GCRYPT_NO_DEPRECATED + * to properly hide all deprecated functionality. + * http://svnweb.freebsd.org/ports/head/security/libgcrypt/files/patch-src__gcrypt.h.in + */ +# define GCRYPT_NO_DEPRECATED # include # if defined __APPLE__ /* Re enable deprecation warnings */ @@ -3366,9 +3371,17 @@ static int network_init (void) have_init = 1; #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)