projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'sh/collectd-4.5' into sh/collectd-4.6
[collectd.git]
/
src
/
rrdtool.c
diff --git
a/src/rrdtool.c
b/src/rrdtool.c
index
9b236cb
..
b80e110
100644
(file)
--- a/
src/rrdtool.c
+++ b/
src/rrdtool.c
@@
-223,7
+223,7
@@
static int value_list_to_string (char *buffer, int buffer_len,
} /* int value_list_to_string */
static int value_list_to_filename (char *buffer, int buffer_len,
} /* int value_list_to_string */
static int value_list_to_filename (char *buffer, int buffer_len,
- const data_set_t *ds, const value_list_t *vl)
+ const data_set_t
__attribute__((unused))
*ds, const value_list_t *vl)
{
int offset = 0;
int status;
{
int offset = 0;
int status;
@@
-266,7
+266,7
@@
static int value_list_to_filename (char *buffer, int buffer_len,
return (0);
} /* int value_list_to_filename */
return (0);
} /* int value_list_to_filename */
-static void *rrd_queue_thread (void *data)
+static void *rrd_queue_thread (void
__attribute__((unused))
*data)
{
struct timeval tv_next_update;
struct timeval tv_now;
{
struct timeval tv_next_update;
struct timeval tv_now;
@@
-279,6
+279,7
@@
static void *rrd_queue_thread (void *data)
rrd_cache_t *cache_entry;
char **values;
int values_num;
rrd_cache_t *cache_entry;
char **values;
int values_num;
+ int status;
int i;
pthread_mutex_lock (&queue_lock);
int i;
pthread_mutex_lock (&queue_lock);
@@
-286,7
+287,6
@@
static void *rrd_queue_thread (void *data)
while (true)
{
struct timespec ts_wait;
while (true)
{
struct timespec ts_wait;
- int status;
while ((flushq_head == NULL) && (queue_head == NULL)
&& (do_shutdown == 0))
while ((flushq_head == NULL) && (queue_head == NULL)
&& (do_shutdown == 0))
@@
-308,10
+308,9
@@
static void *rrd_queue_thread (void *data)
break;
gettimeofday (&tv_now, /* timezone = */ NULL);
break;
gettimeofday (&tv_now, /* timezone = */ NULL);
- status = timeval_sub_timespec (&tv_next_update, &tv_now,
- &ts_wait);
+ status = timeval_cmp (tv_next_update, tv_now, NULL);
/* We're good to go */
/* We're good to go */
- if (status
!
= 0)
+ if (status
<
= 0)
break;
/* We're supposed to wait a bit with this update, so we'll
break;
/* We're supposed to wait a bit with this update, so we'll
@@
-362,17
+361,28
@@
static void *rrd_queue_thread (void *data)
* we make a copy of it's values */
pthread_mutex_lock (&cache_lock);
* we make a copy of it's values */
pthread_mutex_lock (&cache_lock);
- c_avl_get (cache, queue_entry->filename, (void *) &cache_entry);
+ status = c_avl_get (cache, queue_entry->filename,
+ (void *) &cache_entry);
- values = cache_entry->values;
- values_num = cache_entry->values_num;
+ if (status == 0)
+ {
+ values = cache_entry->values;
+ values_num = cache_entry->values_num;
- cache_entry->values = NULL;
- cache_entry->values_num = 0;
- cache_entry->flags = FLAG_NONE;
+ cache_entry->values = NULL;
+ cache_entry->values_num = 0;
+ cache_entry->flags = FLAG_NONE;
+ }
pthread_mutex_unlock (&cache_lock);
pthread_mutex_unlock (&cache_lock);
+ if (status != 0)
+ {
+ sfree (queue_entry->filename);
+ sfree (queue_entry);
+ continue;
+ }
+
/* Update `tv_next_update' */
if (write_rate > 0.0)
{
/* Update `tv_next_update' */
if (write_rate > 0.0)
{
@@
-626,6
+636,15
@@
static int rrd_cache_insert (const char *filename,
pthread_mutex_lock (&cache_lock);
pthread_mutex_lock (&cache_lock);
+ /* This shouldn't happen, but it did happen at least once, so we'll be
+ * careful. */
+ if (cache == NULL)
+ {
+ pthread_mutex_unlock (&cache_lock);
+ WARNING ("rrdtool plugin: cache == NULL.");
+ return (-1);
+ }
+
c_avl_get (cache, filename, (void *) &rc);
if (rc == NULL)
c_avl_get (cache, filename, (void *) &rc);
if (rc == NULL)
@@
-819,6
+838,8
@@
static int rrd_config (const char *key, const char *value)
{
fprintf (stderr, "rrdtool: `CacheTimeout' must "
"be greater than 0.\n");
{
fprintf (stderr, "rrdtool: `CacheTimeout' must "
"be greater than 0.\n");
+ ERROR ("rrdtool: `CacheTimeout' must "
+ "be greater than 0.\n");
return (1);
}
cache_timeout = tmp;
return (1);
}
cache_timeout = tmp;
@@
-830,6
+851,8
@@
static int rrd_config (const char *key, const char *value)
{
fprintf (stderr, "rrdtool: `CacheFlush' must "
"be greater than 0.\n");
{
fprintf (stderr, "rrdtool: `CacheFlush' must "
"be greater than 0.\n");
+ ERROR ("rrdtool: `CacheFlush' must "
+ "be greater than 0.\n");
return (1);
}
cache_flush_timeout = tmp;
return (1);
}
cache_flush_timeout = tmp;
@@
-873,6
+896,8
@@
static int rrd_config (const char *key, const char *value)
{
fprintf (stderr, "rrdtool: `RRARows' must "
"be greater than 0.\n");
{
fprintf (stderr, "rrdtool: `RRARows' must "
"be greater than 0.\n");
+ ERROR ("rrdtool: `RRARows' must "
+ "be greater than 0.\n");
return (1);
}
rrdcreate_config.rrarows = tmp;
return (1);
}
rrdcreate_config.rrarows = tmp;
@@
-899,6
+924,7
@@
static int rrd_config (const char *key, const char *value)
if (tmp_alloc == NULL)
{
fprintf (stderr, "rrdtool: realloc failed.\n");
if (tmp_alloc == NULL)
{
fprintf (stderr, "rrdtool: realloc failed.\n");
+ ERROR ("rrdtool: realloc failed.\n");
free (value_copy);
return (1);
}
free (value_copy);
return (1);
}
@@
-922,6
+948,8
@@
static int rrd_config (const char *key, const char *value)
{
fprintf (stderr, "rrdtool: `XFF' must "
"be in the range 0 to 1 (exclusive).");
{
fprintf (stderr, "rrdtool: `XFF' must "
"be in the range 0 to 1 (exclusive).");
+ ERROR ("rrdtool: `XFF' must "
+ "be in the range 0 to 1 (exclusive).");
return (1);
}
rrdcreate_config.xff = tmp;
return (1);
}
rrdcreate_config.xff = tmp;