From a6ce2a7be1c651cba36b73b269f792f16425aec7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 20 Apr 2007 09:09:48 +0200 Subject: [PATCH] unixsock plugin: Don't add values to the cache that are older or as old as the values in the cache. --- src/unixsock.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/unixsock.c b/src/unixsock.c index 8524bead..1ddd03cf 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -243,12 +243,24 @@ static int cache_update (const data_set_t *ds, const value_list_t *vl) vc = cache_search (name); + /* pthread_mutex_lock is called by cache_insert. */ if (vc == NULL) return (cache_insert (ds, vl)); assert (vc->values_num == ds->ds_num); assert (vc->values_num == vl->values_len); + /* Avoid floating-point exceptions due to division by zero. */ + if (vc->time >= vl->time) + { + pthread_mutex_unlock (&cache_lock); + ERROR ("unixsock plugin: vc->time >= vl->time. vc->time = %u; " + "vl->time = %u; vl = %s;", + (unsigned int) vc->time, (unsigned int) vl->time, + name); + return (-1); + } /* if (vc->time >= vl->time) */ + /* * Update the values. This is possibly a lot more that you'd expect * because we honor min and max values and handle counter overflows here. -- 2.11.0