From: Luke Heberling Date: Mon, 31 Aug 2009 17:31:30 +0000 (-0700) Subject: network plugin: Fix initialization of the gcrypt library. X-Git-Tag: collectd-4.7.3~6 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5899493b4434ba40638f8a5ffe4cb2e58bead3d4;p=collectd.git network plugin: Fix initialization of the gcrypt library. Subject: Ohhhh jeeee, libgcrypt 1.4.1 + collectd 4.7.2 On Monday 31 August 2009 09:03:37 Sebastian Harl wrote: > Hrm … from a quick look at the libcrypt documentation I suppose we need > to call gcry_control() using the 'GCRYCTL_INIT_SECMEM' command to > explicitly initialize the secure memory. Sounds like this was required > in libgcrypt 1.4.1 but is handled automatically in later versions. > also looks like there's some special initialization necessary for threads. I doubt that this is handled by the new default behavior in 1.4.4. Don't know that it's truly necessary if the network plugin is the only plugin using gcrypt. Here's a patch that works for me with 1.4.1. I followed an example for pthread initialization and initialized gcry to 32k, only since that's apparently the default that's used in 1.4.3. I did it in network.c's module_register function. Kind of an abuse, I know. Luke Heberling Signed-off-by: Florian Forster --- diff --git a/src/network.c b/src/network.c index 0e246c20..791c1993 100644 --- a/src/network.c +++ b/src/network.c @@ -51,6 +51,7 @@ #if HAVE_LIBGCRYPT # include +GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif /* 1500 - 40 - 8 = Ethernet packet - IPv6 header - UDP header */ @@ -3028,6 +3029,12 @@ static int network_flush (int timeout, void module_register (void) { +#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); +#endif + plugin_register_complex_config ("network", network_config); plugin_register_init ("network", network_init); plugin_register_flush ("network", network_flush,