summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e1bfa71)
raw | patch | inline | side by side (parent: e1bfa71)
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
diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c
index 8573579166ab7e0aa13078d934ec92ffbf30324e..c9e49f8070536e8d1b99044c74fa0352b7c40178 100644 (file)
--- a/src/daemon/collectd.c
+++ b/src/daemon/collectd.c
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);
* something wrong.
*/
if (init_global_variables () != 0)
- return (1);
+ exit (EXIT_FAILURE);
if (test_config)
return (0);
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index d4b962fb5647cc7bdff4a0139554619d7b8c7d97..d9f8da8c04a2270a0bdff44537ec2dcc0e55e2f5 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));
+ 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)
{
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)
{
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; "
diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h
index de42c068f536bf462d86659b30d677b9efaaeb1f..9c1d72e107b3d1b1f2c11a06593b33eb2605d515 100644 (file)
--- a/src/daemon/plugin.h
+++ b/src/daemon/plugin.h
};
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
{
diff --git a/src/network.c b/src/network.c
index 9a0f429aad88b64bca940484f107978c0f8d0016..f6815f6db82cfa6f5724e310bf4e18562f81c5dc 100644 (file)
--- a/src/network.c
+++ b/src/network.c
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
index 44660638c4234b79a85e77566f338b7383f33bcd..a99dad0b1a3a1358612bf7ee59fc1971a3b93b25 100644 (file)
_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));