From: Florian Forster Date: Sat, 25 May 2013 08:31:54 +0000 (+0200) Subject: src/plugin.c: Move the perl and python "global" magic to plugin_load(). X-Git-Tag: collectd-5.4.0~39 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=003c6e86b480;p=collectd.git src/plugin.c: Move the perl and python "global" magic to plugin_load(). The config file handling is really not the best place to have this. Also, the feature I'm working on would have to copy this magic if left in the config code, and I *really* don't want that. --- diff --git a/src/configfile.c b/src/configfile.c index ac5e8edc..e680aba7 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -277,21 +277,6 @@ static int dispatch_loadplugin (const oconfig_item_t *ci) memset (&ctx, 0, sizeof (ctx)); ctx.interval = cf_get_default_interval (); - /* - * XXX: Magic at work: - * - * Some of the language bindings, for example the Python and Perl - * plugins, need to be able to export symbols to the scripts they run. - * For this to happen, the "Globals" flag needs to be set. - * Unfortunately, this technical detail is hard to explain to the - * average user and she shouldn't have to worry about this, ideally. - * So in order to save everyone's sanity use a different default for a - * handful of special plugins. --octo - */ - if ((strcasecmp ("Perl", name) == 0) - || (strcasecmp ("Python", name) == 0)) - flags |= PLUGIN_FLAGS_GLOBAL; - for (i = 0; i < ci->children_num; ++i) { if (strcasecmp("Globals", ci->children[i].key) == 0) cf_util_get_flag (ci->children + i, &flags, PLUGIN_FLAGS_GLOBAL); diff --git a/src/plugin.c b/src/plugin.c index 386be326..894b0e51 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -901,6 +901,21 @@ int plugin_load (char const *plugin_name, uint32_t flags) dir = plugin_get_dir (); ret = 1; + /* + * XXX: Magic at work: + * + * Some of the language bindings, for example the Python and Perl + * plugins, need to be able to export symbols to the scripts they run. + * For this to happen, the "Globals" flag needs to be set. + * Unfortunately, this technical detail is hard to explain to the + * average user and she shouldn't have to worry about this, ideally. + * So in order to save everyone's sanity use a different default for a + * handful of special plugins. --octo + */ + if ((strcasecmp ("perl", plugin_name) == 0) + || (strcasecmp ("python", plugin_name) == 0)) + flags |= PLUGIN_FLAGS_GLOBAL; + /* `cpu' should not match `cpufreq'. To solve this we add `.so' to the * type when matching the filename */ status = ssnprintf (typename, sizeof (typename), "%s.so", plugin_name);