From: Sebastian Harl Date: Sat, 8 Aug 2015 07:57:48 +0000 (+0200) Subject: plugin: Report an error when writing to the store with no writers. X-Git-Tag: sysdb-0.8.0~50 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=8cc1ac55b3c1dc804d9e6bb516975ba3d6e93b67;ds=sidebyside plugin: Report an error when writing to the store with no writers. --- diff --git a/src/core/plugin.c b/src/core/plugin.c index 26b1408..da8a485 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -1465,6 +1465,12 @@ sdb_plugin_store_host(const char *name, sdb_time_t last_update) if (! name) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store host: " + "no writers registered"); + return -1; + } + iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { writer_t *writer = WRITER(sdb_llist_iter_get_next(iter)); @@ -1488,6 +1494,12 @@ sdb_plugin_store_service(const char *hostname, const char *name, if ((! hostname) || (! name)) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store service: " + "no writers registered"); + return -1; + } + iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { writer_t *writer = WRITER(sdb_llist_iter_get_next(iter)); @@ -1512,6 +1524,12 @@ sdb_plugin_store_metric(const char *hostname, const char *name, if ((! hostname) || (! name)) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store metric: " + "no writers registered"); + return -1; + } + if (store && ((! store->type) || (! store->id))) store = NULL; @@ -1539,6 +1557,12 @@ sdb_plugin_store_attribute(const char *hostname, const char *key, if ((! hostname) || (! key) || (! value)) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store attribute: " + "no writers registered"); + return -1; + } + iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { writer_t *writer = WRITER(sdb_llist_iter_get_next(iter)); @@ -1563,6 +1587,12 @@ sdb_plugin_store_service_attribute(const char *hostname, const char *service, if ((! hostname) || (! service) || (! key) || (! value)) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store service attribute: " + "no writers registered"); + return -1; + } + iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { writer_t *writer = WRITER(sdb_llist_iter_get_next(iter)); @@ -1587,6 +1617,12 @@ sdb_plugin_store_metric_attribute(const char *hostname, const char *metric, if ((! hostname) || (! metric) || (! key) || (! value)) return -1; + if (! sdb_llist_len(writer_list)) { + sdb_log(SDB_LOG_ERR, "core: Cannot store metric attribute: " + "no writers registered"); + return -1; + } + iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { writer_t *writer = WRITER(sdb_llist_iter_get_next(iter));