projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e1bfa71
)
src/daemon/plugin.c: Initialize vl->host in plugin_value_list_clone().
author
Florian Forster
<octo@collectd.org>
Wed, 21 Sep 2016 09:28:11 +0000
(11:28 +0200)
committer
Florian Forster
<octo@collectd.org>
Wed, 21 Sep 2016 09:28:11 +0000
(11:28 +0200)
Issue: #1951
src/daemon/collectd.c
patch
|
blob
|
history
src/daemon/plugin.c
patch
|
blob
|
history
src/daemon/plugin.h
patch
|
blob
|
history
src/network.c
patch
|
blob
|
history
src/utils_vl_lookup_test.c
patch
|
blob
|
history
diff --git
a/src/daemon/collectd.c
b/src/daemon/collectd.c
index
8573579
..
c9e49f8
100644
(file)
--- a/
src/daemon/collectd.c
+++ b/
src/daemon/collectd.c
@@
-101,7
+101,7
@@
static int init_hostname (void)
int status;
str = global_option_get ("Hostname");
int status;
str = global_option_get ("Hostname");
- if (
str != NULL
)
+ if (
(str != NULL) && (str[0] != 0)
)
{
sstrncpy (hostname_g, str, sizeof (hostname_g));
return (0);
{
sstrncpy (hostname_g, str, sizeof (hostname_g));
return (0);
@@
-602,7
+602,7
@@
int main (int argc, char **argv)
* something wrong.
*/
if (init_global_variables () != 0)
* something wrong.
*/
if (init_global_variables () != 0)
-
return (1
);
+
exit (EXIT_FAILURE
);
if (test_config)
return (0);
if (test_config)
return (0);
diff --git
a/src/daemon/plugin.c
b/src/daemon/plugin.c
index
d4b962f
..
d9f8da8
100644
(file)
--- a/
src/daemon/plugin.c
+++ b/
src/daemon/plugin.c
@@
-723,6
+723,9
@@
static value_list_t *plugin_value_list_clone (value_list_t const *vl_orig) /* {{
return (NULL);
memcpy (vl, vl_orig, sizeof (*vl));
return (NULL);
memcpy (vl, vl_orig, sizeof (*vl));
+ if (vl->host[0] == 0)
+ sstrncpy (vl->host, hostname_g, sizeof (vl->host));
+
vl->values = calloc (vl_orig->values_len, sizeof (*vl->values));
if (vl->values == NULL)
{
vl->values = calloc (vl_orig->values_len, sizeof (*vl->values));
if (vl->values == NULL)
{
@@
-2083,10
+2086,14
@@
static int plugin_dispatch_values_internal (value_list_t *vl)
data_set_t *ds;
data_set_t *ds;
- int free_meta_data = 0;
+ _Bool free_meta_data = 0;
+
+ assert (vl != NULL);
- assert(vl);
- assert(vl->plugin);
+ /* These fields are initialized by plugin_value_list_clone() if needed: */
+ assert (vl->host[0] != 0);
+ assert (vl->time != 0); /* The time is determined at _enqueue_ time. */
+ assert (vl->interval != 0);
if (vl->type[0] == 0 || vl->values == NULL || vl->values_len < 1)
{
if (vl->type[0] == 0 || vl->values == NULL || vl->values_len < 1)
{
@@
-2126,11
+2133,6
@@
static int plugin_dispatch_values_internal (value_list_t *vl)
return (-1);
}
return (-1);
}
- /* Assured by plugin_value_list_clone(). The time is determined at
- * _enqueue_ time. */
- assert (vl->time != 0);
- assert (vl->interval != 0);
-
DEBUG ("plugin_dispatch_values: time = %.3f; interval = %.3f; "
"host = %s; "
"plugin = %s; plugin_instance = %s; "
DEBUG ("plugin_dispatch_values: time = %.3f; interval = %.3f; "
"host = %s; "
"plugin = %s; plugin_instance = %s; "
diff --git
a/src/daemon/plugin.h
b/src/daemon/plugin.h
index
de42c06
..
9c1d72e
100644
(file)
--- a/
src/daemon/plugin.h
+++ b/
src/daemon/plugin.h
@@
-110,9
+110,7
@@
struct value_list_s
};
typedef struct value_list_s value_list_t;
};
typedef struct value_list_s value_list_t;
-#define VALUE_LIST_INIT { NULL, 0, 0, plugin_get_interval (), \
- "localhost", "", "", "", "", NULL }
-#define VALUE_LIST_STATIC { NULL, 0, 0, 0, "localhost", "", "", "", "", NULL }
+#define VALUE_LIST_INIT { .values = NULL, .meta = NULL }
struct data_source_s
{
struct data_source_s
{
diff --git
a/src/network.c
b/src/network.c
index
9a0f429
..
f6815f6
100644
(file)
--- a/
src/network.c
+++ b/
src/network.c
@@
-303,7
+303,7
@@
static char *send_buffer;
static char *send_buffer_ptr;
static int send_buffer_fill;
static cdtime_t send_buffer_last_update;
static char *send_buffer_ptr;
static int send_buffer_fill;
static cdtime_t send_buffer_last_update;
-static value_list_t send_buffer_vl = VALUE_LIST_
STATIC
;
+static value_list_t send_buffer_vl = VALUE_LIST_
INIT
;
static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
/* XXX: These counters are incremented from one place only. The spot in which
static pthread_mutex_t send_buffer_lock = PTHREAD_MUTEX_INITIALIZER;
/* XXX: These counters are incremented from one place only. The spot in which
diff --git
a/src/utils_vl_lookup_test.c
b/src/utils_vl_lookup_test.c
index
4466063
..
a99dad0
100644
(file)
--- a/
src/utils_vl_lookup_test.c
+++ b/
src/utils_vl_lookup_test.c
@@
-111,7
+111,7
@@
static int checked_lookup_search (lookup_t *obj,
_Bool expect_new)
{
int status;
_Bool expect_new)
{
int status;
- value_list_t vl = VALUE_LIST_
STATIC
;
+ value_list_t vl = VALUE_LIST_
INIT
;
data_set_t const *ds = &ds_unknown;
strncpy (vl.host, host, sizeof (vl.host));
data_set_t const *ds = &ds_unknown;
strncpy (vl.host, host, sizeof (vl.host));