Code

store: Fixed handling of metric store values.
[sysdb.git] / src / core / plugin.c
index da77f8e57a637426894a1a425498b0216cd8ff7c..f581eb1629fbe3f043c02e13f6a4f3799de9b6d4 100644 (file)
@@ -251,26 +251,6 @@ plugin_unregister_by_name(const char *plugin_name)
        /* else: other callbacks still reference it */
 } /* plugin_unregister_by_name */
 
-static void
-plugin_unregister_all(void)
-{
-       size_t i;
-
-       for (i = 0; i < SDB_STATIC_ARRAY_LEN(all_lists); ++i) {
-               const char  *type =  all_lists[i].type;
-               sdb_llist_t *list = *all_lists[i].list;
-
-               size_t len = sdb_llist_len(list);
-
-               if (! len)
-                       continue;
-
-               sdb_llist_clear(list);
-               sdb_log(SDB_LOG_INFO, "core: Unregistered %zu %s callback%s",
-                               len, type, len == 1 ? "" : "s");
-       }
-} /* plugin_unregister_all */
-
 /*
  * private types
  */
@@ -889,6 +869,26 @@ sdb_plugin_register_writer(const char *name,
        return 0;
 } /* sdb_store_register_writer */
 
+void
+sdb_plugin_unregister_all(void)
+{
+       size_t i;
+
+       for (i = 0; i < SDB_STATIC_ARRAY_LEN(all_lists); ++i) {
+               const char  *type =  all_lists[i].type;
+               sdb_llist_t *list = *all_lists[i].list;
+
+               size_t len = sdb_llist_len(list);
+
+               if (! len)
+                       continue;
+
+               sdb_llist_clear(list);
+               sdb_log(SDB_LOG_INFO, "core: Unregistered %zu %s callback%s",
+                               len, type, len == 1 ? "" : "s");
+       }
+} /* sdb_plugin_unregister_all */
+
 sdb_plugin_ctx_t
 sdb_plugin_get_ctx(void)
 {
@@ -997,7 +997,7 @@ sdb_plugin_reconfigure_init(void)
                CTX(sdb_llist_iter_get_next(iter))->use_cnt = 0;
        sdb_llist_iter_destroy(iter);
 
-       plugin_unregister_all();
+       sdb_plugin_unregister_all();
        return 0;
 } /* sdb_plugin_reconfigure_init */
 
@@ -1386,7 +1386,7 @@ sdb_plugin_store_metric(const char *hostname, const char *name,
        if ((! hostname) || (! name))
                return -1;
 
-       if ((! store->type) || (! store->id))
+       if (store && ((! store->type) || (! store->id)))
                store = NULL;
 
        iter = sdb_llist_get_iter(writer_list);