X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fperl.c;h=b5965d67c2386cc826502591cb202fe8e44ddd5b;hb=bc7992ed0693313a2b1fe282a5bf23f1cc9f8e42;hp=e6f7de0e0de71ed75647c3f26548e98e3243ff85;hpb=7471e073bff7c9f2542bc1c8ce639b85c5498ba7;p=collectd.git diff --git a/src/perl.c b/src/perl.c index e6f7de0e..b5965d67 100644 --- a/src/perl.c +++ b/src/perl.c @@ -36,7 +36,7 @@ #include #include -#if __GNUC__ +#if defined(COLLECT_DEBUG) && COLLECT_DEBUG && defined(__GNUC__) && __GNUC__ # pragma GCC poison sprintf #endif @@ -640,9 +640,6 @@ static int pplugin_dispatch_values (pTHX_ HV *values) if (NULL != (tmp = hv_fetch (values, "time", 4, 0))) { list.time = (time_t)SvIV (*tmp); } - else { - list.time = time (NULL); - } if (NULL != (tmp = hv_fetch (values, "host", 4, 0))) { sstrncpy (list.host, SvPV_nolen (*tmp), sizeof (list.host)); @@ -1092,7 +1089,7 @@ static XS (Collectd_plugin_log) XSRETURN_EMPTY; } - plugin_log (SvIV (ST (0)), SvPV_nolen (ST (1))); + plugin_log (SvIV (ST (0)), "%s", SvPV_nolen (ST (1))); XSRETURN_YES; } /* static XS (Collectd_plugin_log) */ @@ -1561,7 +1558,9 @@ static int init_pi (int argc, char **argv) PL_exit_flags |= PERL_EXIT_DESTRUCT_END; if (0 != perl_parse (aTHX_ xs_init, argc, argv, NULL)) { - log_err ("init_pi: Unable to bootstrap Collectd."); + SV *err = get_sv ("@", 1); + log_err ("init_pi: Unable to bootstrap Collectd: %s", + SvPV_nolen (err)); perl_destruct (perl_threads->head->interp); perl_free (perl_threads->head->interp); @@ -1768,10 +1767,10 @@ static int perl_config_plugin (pTHX_ oconfig_item_t *ci) if (0 < retvals) { SV *tmp = POPs; if (! SvTRUE (tmp)) - ret = -1; + ret = 1; } else - ret = -1; + ret = 1; PUTBACK; FREETMPS; @@ -1781,30 +1780,44 @@ static int perl_config_plugin (pTHX_ oconfig_item_t *ci) static int perl_config (oconfig_item_t *ci) { + int status = 0; int i = 0; dTHXa (NULL); for (i = 0; i < ci->children_num; ++i) { oconfig_item_t *c = ci->children + i; + int current_status = 0; if (NULL != perl_threads) aTHX = PERL_GET_CONTEXT; if (0 == strcasecmp (c->key, "LoadPlugin")) - perl_config_loadplugin (aTHX_ c); + current_status = perl_config_loadplugin (aTHX_ c); else if (0 == strcasecmp (c->key, "BaseName")) - perl_config_basename (aTHX_ c); + current_status = perl_config_basename (aTHX_ c); else if (0 == strcasecmp (c->key, "EnableDebugger")) - perl_config_enabledebugger (aTHX_ c); + current_status = perl_config_enabledebugger (aTHX_ c); else if (0 == strcasecmp (c->key, "IncludeDir")) - perl_config_includedir (aTHX_ c); + current_status = perl_config_includedir (aTHX_ c); else if (0 == strcasecmp (c->key, "Plugin")) - perl_config_plugin (aTHX_ c); + current_status = perl_config_plugin (aTHX_ c); else + { log_warn ("Ignoring unknown config key \"%s\".", c->key); + current_status = 0; + } + + /* fatal error - it's up to perl_config_* to clean up */ + if (0 > current_status) { + log_err ("Configuration failed with a fatal error - " + "plugin disabled!"); + return current_status; + } + + status += current_status; } - return 0; + return status; } /* static int perl_config (oconfig_item_t *) */ void module_register (void)