int values_num;
gauge_t *gauge;
counter_t *counter;
+ const data_set_t *ds;
time_t time;
struct value_cache_s *next;
} value_cache_t;
}
}
vc->values_num = ds->ds_num;
+ vc->ds = ds;
vc->next = cache_head;
cache_head = vc;
vc->gauge[i] = NAN;
} /* for i = 0 .. ds->ds_num */
+ vc->ds = ds;
vc->time = vl->time;
if (vc->time < cache_oldest)
pthread_mutex_lock (&cache_lock);
+ DBG ("vc = cache_search (%s)", name);
vc = cache_search (name);
- fprintf (fh, "%i", vc->values_num);
- for (i = 0; i < vc->values_num; i++)
+ if (vc == NULL)
{
- if (vc->gauge[i] == NAN)
- fprintf (fh, " NaN");
- else
- fprintf (fh, " %12e", vc->gauge[i]);
+ DBG ("Did not find cache entry.");
+ fprintf (fh, "-1 No such value");
+ }
+ else
+ {
+ DBG ("Found cache entry.");
+ fprintf (fh, "%i", vc->values_num);
+ for (i = 0; i < vc->values_num; i++)
+ {
+ fprintf (fh, " %s=", vc->ds->ds[i].name);
+ if (vc->gauge[i] == NAN)
+ fprintf (fh, "NaN");
+ else
+ fprintf (fh, "%12e", vc->gauge[i]);
+ }
}
/* Free the mutex as soon as possible and definitely before flushing */
while (fgets (buffer, sizeof (buffer), fh) != NULL)
{
- DBG ("fgets -> buffer = %s", buffer);
+ int len;
+
+ len = strlen (buffer);
+ while ((len > 0)
+ && ((buffer[len - 1] == '\n') || (buffer[len - 1] == '\r')))
+ buffer[--len] = '\0';
+
+ if (len == 0)
+ continue;
+
+ DBG ("fgets -> buffer = %s; len = %i;", buffer, len);
fields_num = strsplit (buffer, fields,
sizeof (fields) / sizeof (fields[0]));