projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Auto-Merge pull request #2784 from rpv-tomsk/fix-5.8
[collectd.git]
/
src
/
daemon
/
plugin.c
diff --git
a/src/daemon/plugin.c
b/src/daemon/plugin.c
index
0451e8a
..
9b75f69
100644
(file)
--- a/
src/daemon/plugin.c
+++ b/
src/daemon/plugin.c
@@
-191,16
+191,21
@@
static int plugin_update_internal_statistics(void) { /* {{{ */
return 0;
} /* }}} int plugin_update_internal_statistics */
return 0;
} /* }}} int plugin_update_internal_statistics */
-static void
destroy_callback(callback_func_t *cf
) /* {{{ */
+static void
free_userdata(user_data_t const *ud
) /* {{{ */
{
{
- if (
cf
== NULL)
+ if (
ud
== NULL)
return;
return;
- if ((cf->cf_udata.data != NULL) && (cf->cf_udata.free_func != NULL)) {
- cf->cf_udata.free_func(cf->cf_udata.data);
- cf->cf_udata.data = NULL;
- cf->cf_udata.free_func = NULL;
+ if ((ud->data != NULL) && (ud->free_func != NULL)) {
+ ud->free_func(ud->data);
}
}
+} /* }}} void free_userdata */
+
+static void destroy_callback(callback_func_t *cf) /* {{{ */
+{
+ if (cf == NULL)
+ return;
+ free_userdata(&cf->cf_udata);
sfree(cf);
} /* }}} void destroy_callback */
sfree(cf);
} /* }}} void destroy_callback */
@@
-345,6
+350,7
@@
static int create_register_callback(llist_t **list, /* {{{ */
cf = calloc(1, sizeof(*cf));
if (cf == NULL) {
cf = calloc(1, sizeof(*cf));
if (cf == NULL) {
+ free_userdata(ud);
ERROR("plugin: create_register_callback: calloc failed.");
return -1;
}
ERROR("plugin: create_register_callback: calloc failed.");
return -1;
}
@@
-1120,8
+1126,7
@@
static int plugin_insert_read(read_func_t *rf) {
if (le != NULL) {
pthread_mutex_unlock(&read_lock);
WARNING("The read function \"%s\" is already registered. "
if (le != NULL) {
pthread_mutex_unlock(&read_lock);
WARNING("The read function \"%s\" is already registered. "
- "Check for duplicate \"LoadPlugin\" lines "
- "in your configuration!",
+ "Check for duplicates in your configuration!",
rf->rf_name);
return EINVAL;
}
rf->rf_name);
return EINVAL;
}
@@
-1186,6
+1191,7
@@
int plugin_register_complex_read(const char *group, const char *name,
rf = calloc(1, sizeof(*rf));
if (rf == NULL) {
rf = calloc(1, sizeof(*rf));
if (rf == NULL) {
+ free_userdata(user_data);
ERROR("plugin_register_complex_read: calloc failed.");
return ENOMEM;
}
ERROR("plugin_register_complex_read: calloc failed.");
return ENOMEM;
}
@@
-1211,6
+1217,7
@@
int plugin_register_complex_read(const char *group, const char *name,
status = plugin_insert_read(rf);
if (status != 0) {
status = plugin_insert_read(rf);
if (status != 0) {
+ free_userdata(&rf->rf_udata);
sfree(rf->rf_name);
sfree(rf);
}
sfree(rf->rf_name);
sfree(rf);
}
@@
-1303,11
+1310,7
@@
int plugin_register_flush(const char *name, plugin_flush_cb callback,
});
sfree(flush_name);
});
sfree(flush_name);
- if (status != 0) {
- sfree(cb->name);
- sfree(cb);
- return status;
- }
+ return status;
}
return 0;
}
return 0;
@@
-1319,8
+1322,7
@@
int plugin_register_missing(const char *name, plugin_missing_cb callback,
} /* int plugin_register_missing */
int plugin_register_shutdown(const char *name, int (*callback)(void)) {
} /* int plugin_register_missing */
int plugin_register_shutdown(const char *name, int (*callback)(void)) {
- return create_register_callback(&list_shutdown, name, (void *)callback,
- NULL);
+ return create_register_callback(&list_shutdown, name, (void *)callback, NULL);
} /* int plugin_register_shutdown */
static void plugin_free_data_sets(void) {
} /* int plugin_register_shutdown */
static void plugin_free_data_sets(void) {
@@
-1871,23
+1873,16
@@
int plugin_shutdown_all(void) {
int plugin_dispatch_missing(const value_list_t *vl) /* {{{ */
{
int plugin_dispatch_missing(const value_list_t *vl) /* {{{ */
{
- llentry_t *le;
-
if (list_missing == NULL)
return 0;
if (list_missing == NULL)
return 0;
- le = llist_head(list_missing);
+ l
lentry_t *l
e = llist_head(list_missing);
while (le != NULL) {
while (le != NULL) {
- callback_func_t *cf;
- plugin_missing_cb callback;
- plugin_ctx_t old_ctx;
- int status;
+ callback_func_t *cf = le->value;
+ plugin_ctx_t old_ctx = plugin_set_ctx(cf->cf_ctx);
+ plugin_missing_cb callback = cf->cf_callback;
- cf = le->value;
- old_ctx = plugin_set_ctx(cf->cf_ctx);
- callback = cf->cf_callback;
-
- status = (*callback)(vl, &cf->cf_udata);
+ int status = (*callback)(vl, &cf->cf_udata);
plugin_set_ctx(old_ctx);
if (status != 0) {
if (status < 0) {
plugin_set_ctx(old_ctx);
if (status != 0) {
if (status < 0) {
@@
-1909,8
+1904,6
@@
static int plugin_dispatch_values_internal(value_list_t *vl) {
int status;
static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
int status;
static c_complain_t no_write_complaint = C_COMPLAIN_INIT_STATIC;
- data_set_t *ds;
-
_Bool free_meta_data = 0;
assert(vl != NULL);
_Bool free_meta_data = 0;
assert(vl != NULL);
@@
-1946,6
+1939,7
@@
static int plugin_dispatch_values_internal(value_list_t *vl) {
return -1;
}
return -1;
}
+ data_set_t *ds = NULL;
if (c_avl_get(data_sets, vl->type, (void *)&ds) != 0) {
char ident[6 * DATA_MAX_NAME_LEN];
if (c_avl_get(data_sets, vl->type, (void *)&ds) != 0) {
char ident[6 * DATA_MAX_NAME_LEN];