From 66b400ab01b8133e450bb002e175117a1ab6f9ae Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Sun, 26 Jan 2014 20:43:19 -0500 Subject: [PATCH] Call curl_global_init() in _init of plugins using curl 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 | 1 + src/curl_json.c | 9 +++++++++ src/curl_xml.c | 9 +++++++++ src/write_http.c | 9 +++++++++ 4 files changed, 28 insertions(+) diff --git a/src/curl.c b/src/curl.c index 3899aaab..8d2893f0 100644 --- a/src/curl.c +++ b/src/curl.c @@ -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 */ diff --git a/src/curl_json.c b/src/curl_json.c index 24e1df1e..09489626 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -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 : */ diff --git a/src/curl_xml.c b/src/curl_xml.c index b941f02a..e31e73d2 100644 --- a/src/curl_xml.c +++ b/src/curl_xml.c @@ -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 : */ diff --git a/src/write_http.c b/src/write_http.c index 62c73b09..04c637b2 100644 --- a/src/write_http.c +++ b/src/write_http.c @@ -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 : */ -- 2.30.2