summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: edec093)
raw | patch | inline | side by side (parent: edec093)
author | Florian Forster <octo@huhu.verplant.org> | |
Thu, 21 Dec 2006 12:27:56 +0000 (13:27 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Thu, 21 Dec 2006 19:18:03 +0000 (20:18 +0100) |
This fixes the first part of the bug reported by Max Kellermann.
src/collectd.c | patch | blob | history | |
src/network.c | patch | blob | history |
diff --git a/src/collectd.c b/src/collectd.c
index 0d9c90fce19a5dd2fe1e222c8a61f3d07e63a67d..c9385d95796419da090cdf6dd7290ab3458d831d 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
#if HAVE_LIBRRD
static int start_server (void)
{
- /* FIXME use stack here! */
char *host;
char *type;
char *instance;
char *values;
- while (loop == 0)
+ int error_counter = 0;
+ int status;
+
+ while ((loop == 0) && (error_counter < 3))
{
- if (network_receive (&host, &type, &instance, &values) == 0)
- plugin_write (host, type, instance, values);
+ status = network_receive (&host, &type, &instance, &values);
+
+ if (status != 0)
+ {
+ if (status < 0)
+ error_counter++;
+ continue;
+ }
+ error_counter = 0;
+
+ plugin_write (host, type, instance, values);
if (host != NULL) free (host); host = NULL;
if (type != NULL) free (type); type = NULL;
diff --git a/src/network.c b/src/network.c
index 22e911a87b8e4d4fe89d805abc9c9559ce2463c6..c233de6826ebab9c7c7de45ef24042de0791fefb 100644 (file)
--- a/src/network.c
+++ b/src/network.c
{
syslog (LOG_WARNING, "Invalid message from `%s'", *host);
free (*host); *host = NULL;
- return (-1);
+ return (1);
}
if ((*type = strdup (fields[0])) == NULL)