From: Sebastian Harl Date: Sat, 19 Jul 2014 11:45:12 +0000 (+0200) Subject: plugin: Report an error if a collector's interval cannot be determined. X-Git-Tag: sysdb-0.3.0~48 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=52fd6fa603286c39f3b4e8b5e3f28b13d5265949 plugin: Report an error if a collector's interval cannot be determined. Else, we'll get weird behavior when, for example, using LoadPlugin instead of LoadBackend in sysdbd. --- diff --git a/src/core/plugin.c b/src/core/plugin.c index 806e13c..919df2b 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -751,12 +751,16 @@ sdb_plugin_register_collector(const char *name, sdb_plugin_collector_cb callback if (interval) SDB_PLUGIN_CCB(obj)->ccb_interval = *interval; else { - sdb_time_t tmp = sdb_plugin_get_ctx().interval; + ctx_t *ctx = ctx_get(); - if (tmp > 0) - SDB_PLUGIN_CCB(obj)->ccb_interval = tmp; - else - SDB_PLUGIN_CCB(obj)->ccb_interval = 0; + if (! ctx) { + sdb_log(SDB_LOG_ERR, "core: Cannot determine interval " + "for collector %s; none specified and no plugin " + "context found", cb_name); + return -1; + } + + SDB_PLUGIN_CCB(obj)->ccb_interval = ctx->public.interval; } if (! (SDB_PLUGIN_CCB(obj)->ccb_next_update = sdb_gettime())) {