Code

plugin: Report an error if a collector's interval cannot be determined.
authorSebastian Harl <sh@tokkee.org>
Sat, 19 Jul 2014 11:45:12 +0000 (13:45 +0200)
committerSebastian Harl <sh@tokkee.org>
Sat, 19 Jul 2014 11:45:12 +0000 (13:45 +0200)
Else, we'll get weird behavior when, for example, using LoadPlugin instead of
LoadBackend in sysdbd.

src/core/plugin.c

index 806e13c2f717f27b339ffd42b4cf43f4e2c3575b..919df2b3c982fed934b0495849817936907d9253 100644 (file)
@@ -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())) {