summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c639d7)
raw | patch | inline | side by side (parent: 1c639d7)
author | Florian Forster <octo@collectd.org> | |
Thu, 17 Dec 2015 13:25:19 +0000 (14:25 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 17 Dec 2015 13:25:19 +0000 (14:25 +0100) |
Since version 5.3, a write queue is used. This means that the
plugin_dispatch_values() call will create a copy of the value list and
return quickly. Creating yet another copy here is therefore not as useful
anymore.
CID: 38114
plugin_dispatch_values() call will create a copy of the value list and
return quickly. Creating yet another copy here is therefore not as useful
anymore.
CID: 38114
src/gmond.c | patch | blob | history |
diff --git a/src/gmond.c b/src/gmond.c
index 629a9ad2409b5982ddf265956abebef2464ea446..b4ecfefc6d6afef57eb6f0cb42cb79136e6d8b68 100644 (file)
--- a/src/gmond.c
+++ b/src/gmond.c
/**
* collectd - src/gmond.c
- * Copyright (C) 2009,2010 Florian octo Forster
+ * Copyright (C) 2009-2015 Florian octo Forster
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
return (se);
} /* }}} staging_entry_t *staging_entry_get */
-static int staging_entry_submit (const char *host, const char *name, /* {{{ */
- staging_entry_t *se)
-{
- value_list_t vl;
- value_t values[se->vl.values_len];
-
- if (se->vl.interval == 0)
- {
- /* No meta data has been received for this metric yet. */
- se->flags = 0;
- pthread_mutex_unlock (&staging_lock);
- request_meta_data (host, name);
- return (0);
- }
-
- se->flags = 0;
-
- memcpy (values, se->vl.values, sizeof (values));
- memcpy (&vl, &se->vl, sizeof (vl));
-
- /* Unlock before calling `plugin_dispatch_values'.. */
- pthread_mutex_unlock (&staging_lock);
-
- vl.values = values;
-
- plugin_dispatch_values (&vl);
-
- return (0);
-} /* }}} int staging_entry_submit */
-
static int staging_entry_update (const char *host, const char *name, /* {{{ */
const char *type, const char *type_instance,
int ds_index, int ds_type, value_t value)
@@ -568,17 +538,30 @@ static int staging_entry_update (const char *host, const char *name, /* {{{ */
se->flags |= (0x01 << ds_index);
- /* Check if all values have been set and submit if so. */
- if (se->flags == ((0x01 << se->vl.values_len) - 1))
+ /* Check if all data sources have been set. If not, return here. */
+ if (se->flags != ((0x01 << se->vl.values_len) - 1))
{
- /* `staging_lock' is unlocked in `staging_entry_submit'. */
- staging_entry_submit (host, name, se);
+ pthread_mutex_unlock (&staging_lock);
+ return (0);
}
- else
+
+ /* Check if the interval of this metric is known. If not, request meta data
+ * and return. */
+ if (se->vl.interval == 0)
{
+ /* No meta data has been received for this metric yet. */
+ se->flags = 0;
pthread_mutex_unlock (&staging_lock);
+
+ request_meta_data (host, name);
+ return (0);
}
+ plugin_dispatch_values (&se->vl);
+
+ se->flags = 0;
+ pthread_mutex_unlock (&staging_lock);
+
return (0);
} /* }}} int staging_entry_update */