From: Pavel Rochnyack Date: Fri, 16 Sep 2016 02:58:44 +0000 (+0600) Subject: perl plugin: Renamed and documented "RegisterLegacyFlush" option. X-Git-Tag: collectd-5.7.0~78 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3e36ac34460b6be8388ac376ab7a4e2e990870ec;p=collectd.git perl plugin: Renamed and documented "RegisterLegacyFlush" option. --- diff --git a/src/collectd-perl.pod b/src/collectd-perl.pod index f1913b8e..9af3c0c9 100644 --- a/src/collectd-perl.pod +++ b/src/collectd-perl.pod @@ -75,6 +75,20 @@ Adds I to the B<@INC> array. This is the same as using the B<-IDir> command line option or B in the source code. Please note that it only has effect on plugins loaded after this option. +=item B I + +The C used to register one flush callback (called B<"perl">) and +call all Perl-based flush handlers when this callback was called. Newer versions +of the plugin wrap the Perl flush handlers and register them directly with the +daemon I to the legacy B<"perl"> callback. This allows to call +specific Perl flush handlers, but has the downside that flushing I plugins +now calls the Perl flush handlers twice (once directly and once via the legacy +callback). Unfortunately, removing the B<"perl"> callback would break backwards +compatibility. + +This option allows you to disable the legacy B<"perl"> flush callback if you care +about the double call and don't call the B<"perl"> callback in your setup. + =back =head1 WRITING YOUR OWN PLUGINS diff --git a/src/perl.c b/src/perl.c index 3f430bd1..4a11d6c1 100644 --- a/src/perl.c +++ b/src/perl.c @@ -185,7 +185,7 @@ extern char **environ; * private variables */ -static int flush_callback_registered = 0; +static _Bool register_legacy_flush = 1; /* if perl_threads != NULL perl_threads->head must * point to the "base" thread */ @@ -1699,8 +1699,8 @@ static void _plugin_register_generic_userdata (pTHX, int type, const char *desc) ret = plugin_register_notification(pluginname, perl_notify, &userdata); } else if (PLUGIN_FLUSH == type) { - if (0 == flush_callback_registered) { /* For collectd-5.6 only, #1731 */ - flush_callback_registered++; + if (1 == register_legacy_flush) { /* For collectd-5.7 only, #1731 */ + register_legacy_flush = 0; ret = plugin_register_flush("perl", perl_flush, /* user_data = */ NULL); } @@ -2806,8 +2806,8 @@ static int perl_config (oconfig_item_t *ci) current_status = perl_config_includedir (aTHX_ c); else if (0 == strcasecmp (c->key, "Plugin")) current_status = perl_config_plugin (aTHX_ c); - else if (0 == strcasecmp (c->key, "DisableOldFlush")) - flush_callback_registered++; + else if (0 == strcasecmp (c->key, "RegisterLegacyFlush")) + cf_util_get_boolean (c, ®ister_legacy_flush); else { log_warn ("Ignoring unknown config key \"%s\".", c->key);