summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d728c9a)
raw | patch | inline | side by side (parent: d728c9a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 28 Jan 2007 17:14:07 +0000 (18:14 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 28 Jan 2007 17:14:07 +0000 (18:14 +0100) |
src/unixsock.c | patch | blob | history |
diff --git a/src/unixsock.c b/src/unixsock.c
index 84d49fd617bb0df8a760e7b3b24362c1e8f2e080..21c9cc6525fc6bf5a3b4f05afa7eedbea98b57e7 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
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]));