Hi,

Using the attached dpatch fixes this problem.

-- 
Kind regards,
Met vriendelijke groet,

Pieter Lexis

Kumina bv
www.kumina.nl
kvk nr 14095795
#! /bin/sh /usr/share/dpatch/dpatch-run
## correcty-init-gcrypt.dpatch by Pieter Lexis <pie...@kumina.nl>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fixes #735173
## DP: This combines upstream commits 0ec776a and d219776

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' 
'--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' 
collectd-5.1.0~/src/network.c collectd-5.1.0/src/network.c
--- collectd-5.1.0~/src/network.c       2014-01-15 08:31:30.000000000 +0000
+++ collectd-5.1.0/src/network.c        2014-01-15 08:38:24.995530906 +0000
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Authors:
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <octo at collectd.org>
  *   Aman Gupta <aman at tmm1.net>
  **/
 
@@ -476,6 +476,20 @@
 } /* }}} int network_dispatch_notification */
 
 #if HAVE_LIBGCRYPT
+static void network_init_gcrypt (void) /* {{{ */
+{
+  /* 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))
+    return;
+
+  gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+  gcry_check_version (NULL); /* before calling *almost* any other functions */
+  gcry_control (GCRYCTL_INIT_SECMEM, 32768);
+  gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
+} /* }}} void network_init_gcrypt */
+
 static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, /* {{{ */
     const void *iv, size_t iv_size, const char *username)
 {
@@ -2008,6 +2022,8 @@
        {
                if (se->data.client.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
+
                        if ((se->data.client.username == NULL)
                                        || (se->data.client.password == NULL))
                        {
@@ -2026,6 +2042,8 @@
        {
                if (se->data.server.security_level > SECURITY_LEVEL_NONE)
                {
+                       network_init_gcrypt ();
+
                        if (se->data.server.auth_file == NULL)
                        {
                                ERROR ("network plugin: Server socket with "
@@ -3350,9 +3368,7 @@
        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);
+       network_init_gcrypt ();
 #endif
 
        if (network_config_stats != 0)

Reply via email to