summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2006-04-17 14:40:05 +0000
committerStef Walter <stef@memberwebs.com>2006-04-17 14:40:05 +0000
commitdbac79d7dda7544f5b6d4570ca61ba0ac9ca2628 (patch)
tree95692f3e295ce735df70b0c1b5962ee02f35c2e7
parent07ae133abf41af9d24a3a49196ac8c919b849629 (diff)
Don't choke on 'interval' being used when no poll.
-rw-r--r--daemon/config.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/daemon/config.c b/daemon/config.c
index 89ac6f9..0f68c79 100644
--- a/daemon/config.c
+++ b/daemon/config.c
@@ -131,52 +131,52 @@ config_done(config_ctx* ctx)
char *t;
/* No polling specified */
- if(!ctx->items)
- return;
+ if(ctx->items)
+ {
+ /* Make sure we found an interval */
+ if(ctx->interval == 0)
+ errx(2, "%s: no interval specified", ctx->confname);
- /* Make sure we found an interval */
- if(ctx->interval == 0)
- errx(2, "%s: no interval specified", ctx->confname);
+ if(ctx->timeout == 0)
+ ctx->timeout = g_state.timeout;
- if(ctx->timeout == 0)
- ctx->timeout = g_state.timeout;
+ /* And a nice key for lookups */
+ snprintf(key, sizeof(key), "%d-%d:%s/%s.rrd", ctx->timeout,
+ ctx->interval, g_state.rrddir, ctx->confname);
+ key[sizeof(key) - 1] = 0;
- /* And a nice key for lookups */
- snprintf(key, sizeof(key), "%d-%d:%s/%s.rrd", ctx->timeout,
- ctx->interval, g_state.rrddir, ctx->confname);
- key[sizeof(key) - 1] = 0;
+ /* See if we have one of these pollers already */
+ poll = (rb_poller*)hsh_get(g_state.poll_by_key, key, -1);
+ if(!poll)
+ {
+ poll = (rb_poller*)xcalloc(sizeof(*poll));
+ if(!hsh_set(g_state.poll_by_key, key, -1, poll))
+ errx(1, "out of memory");
- /* See if we have one of these pollers already */
- poll = (rb_poller*)hsh_get(g_state.poll_by_key, key, -1);
- if(!poll)
- {
- poll = (rb_poller*)xcalloc(sizeof(*poll));
- if(!hsh_set(g_state.poll_by_key, key, -1, poll))
- errx(1, "out of memory");
+ strcpy(poll->key, key);
+ t = strchr(poll->key, ':');
+ ASSERT(t);
+ poll->rrdname = t + 1;
- strcpy(poll->key, key);
- t = strchr(poll->key, ':');
- ASSERT(t);
- poll->rrdname = t + 1;
+ poll->interval = ctx->interval * 1000;
+ poll->timeout = ctx->timeout * 1000;
- poll->interval = ctx->interval * 1000;
- poll->timeout = ctx->timeout * 1000;
+ /* Add it to the main lists */
+ poll->next = g_state.polls;
+ g_state.polls = poll;
+ }
- /* Add it to the main lists */
- poll->next = g_state.polls;
- g_state.polls = poll;
- }
+ /* Get the last item and add to the list */
+ for(it = ctx->items; it->next; it = it->next)
+ it->poller = poll;
- /* Get the last item and add to the list */
- for(it = ctx->items; it->next; it = it->next)
+ ASSERT(it);
it->poller = poll;
- ASSERT(it);
- it->poller = poll;
-
- /* Add the items to this poller */
- it->next = poll->items;
- poll->items = sort_items_by_host(ctx->items);
+ /* Add the items to this poller */
+ it->next = poll->items;
+ poll->items = sort_items_by_host(ctx->items);
+ }
/*
* This remains allocated for the life of the program as