Code

collectd::unixsock: Fixed a memory leak happening when unloading the module.
[sysdb.git] / src / plugins / backend / collectd / unixsock.c
index b1db539b84738a571a8b456b45658c6a6099593f..8af5327624e135c15796b5e86c1bc6a7878cbedd 100644 (file)
@@ -90,6 +90,8 @@ user_data_destroy(void *obj)
        if (ud->ts_base)
                free(ud->ts_base);
        ud->ts_type = ud->ts_base = NULL;
+
+       free(ud);
 } /* user_data_destroy */
 
 /* store the specified host-name (once per iteration) */
@@ -405,6 +407,18 @@ sdb_collectd_config_instance(oconfig_item_t *ci)
        }
 
        if (ud->ts_type) {
+               /* TODO: add support for other backend types
+                * -> will require different ID generation */
+               if (strcasecmp(ud->ts_type, "rrdtool")
+                               && strcasecmp(ud->ts_type, "rrdcached")) {
+                       sdb_log(SDB_LOG_ERR, "collectd::unixsock backend: "
+                                       "TimeseriesBackend '%s' is not supported - "
+                                       "use 'rrdtool' instead.", ud->ts_type);
+                       ud->ts_type = ud->ts_base = NULL;
+                       user_data_destroy(ud);
+                       return -1;
+               }
+
                ud->ts_type = strdup(ud->ts_type);
                ud->ts_base = strdup(ud->ts_base);
                if ((! ud->ts_type) || (! ud->ts_base)) {