Call curl_global_init() in _init of plugins using curl
authorJeremy Katz <jeremy@katzbox.net>
Mon, 27 Jan 2014 01:43:19 +0000 (20:43 -0500)
committerMarc Fournier <marc.fournier@camptocamp.com>
Sat, 29 Mar 2014 12:27:04 +0000 (13:27 +0100)
Need to call curl_global_init() or curl_easy_init() during init
for plugins when we're still running single threaded.  This
updates the remaining ones

src/curl.c
src/curl_json.c
src/curl_xml.c
src/write_http.c

index 3899aaa..8d2893f 100644 (file)
@@ -566,6 +566,7 @@ static int cc_init (void) /* {{{ */
     INFO ("curl plugin: No pages have been defined.");
     return (-1);
   }
+  curl_global_init (CURL_GLOBAL_SSL);
   return (0);
 } /* }}} int cc_init */
 
index 24e1df1..0948962 100644 (file)
@@ -882,9 +882,18 @@ static int cj_read (user_data_t *ud) /* {{{ */
   return cj_curl_perform (db, db->curl);
 } /* }}} int cj_read */
 
+static int cj_init (void) /* {{{ */
+{
+  /* Call this while collectd is still single-threaded to avoid
+   * initialization issues in libgcrypt. */
+  curl_global_init (CURL_GLOBAL_SSL);
+  return (0);
+} /* }}} int cj_init */
+
 void module_register (void)
 {
   plugin_register_complex_config ("curl_json", cj_config);
+  plugin_register_init ("curl_json", cj_init);
 } /* void module_register */
 
 /* vim: set sw=2 sts=2 et fdm=marker : */
index b941f02..e31e73d 100644 (file)
@@ -926,9 +926,18 @@ static int cx_config (oconfig_item_t *ci) /* {{{ */
   return (0);
 } /* }}} int cx_config */
 
+static int cx_init (void) /* {{{ */
+{
+  /* Call this while collectd is still single-threaded to avoid
+   * initialization issues in libgcrypt. */
+  curl_global_init (CURL_GLOBAL_SSL);
+  return (0);
+} /* }}} int cx_init */
+
 void module_register (void)
 {
   plugin_register_complex_config ("curl_xml", cx_config);
+  plugin_register_init ("curl_xml", cx_init);
 } /* void module_register */
 
 /* vim: set sw=2 sts=2 et fdm=marker : */
index 62c73b0..04c637b 100644 (file)
@@ -656,9 +656,18 @@ static int wh_config (oconfig_item_t *ci) /* {{{ */
         return (0);
 } /* }}} int wh_config */
 
+static int wh_init (void) /* {{{ */
+{
+  /* Call this while collectd is still single-threaded to avoid
+   * initialization issues in libgcrypt. */
+  curl_global_init (CURL_GLOBAL_SSL);
+  return (0);
+} /* }}} int wh_init */
+
 void module_register (void) /* {{{ */
 {
         plugin_register_complex_config ("write_http", wh_config);
+        plugin_register_init ("write_http", wh_init);
 } /* }}} void module_register */
 
 /* vim: set fdm=marker sw=8 ts=8 tw=78 et : */