From eab40ae770c969d6d6871f9a1356115d93e1f3d6 Mon Sep 17 00:00:00 2001 From: "J. Javier Maestro" Date: Sun, 16 Jun 2013 19:37:32 +0200 Subject: [PATCH] write_graphite plugin: avoid flooding the log with the protocol error check Moving the protocol error checking from `wg_callback_init` to `wg_config_node`. This avoids flooding the log, as suggested by Florian Forster (@octo). --- src/write_graphite.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/write_graphite.c b/src/write_graphite.c index c264932f..c1a11df2 100644 --- a/src/write_graphite.c +++ b/src/write_graphite.c @@ -199,14 +199,8 @@ static int wg_callback_init (struct wg_callback *cb) if (0 == strcasecmp ("tcp", protocol)) ai_hints.ai_socktype = SOCK_STREAM; - else if (0 == strcasecmp ("udp", protocol)) - ai_hints.ai_socktype = SOCK_DGRAM; else - { - ERROR ("write_graphite plugin: unknown protocol (%s)", - protocol); - return (-1); - } + ai_hints.ai_socktype = SOCK_DGRAM; ai_list = NULL; @@ -499,7 +493,17 @@ static int wg_config_node (oconfig_item_t *ci) else if (strcasecmp ("Port", child->key) == 0) cf_util_get_service (child, &cb->service); else if (strcasecmp ("Protocol", child->key) == 0) + { cf_util_get_string (child, &cb->protocol); + + if (strcasecmp ("UDP", cb->protocol) != 0 && + strcasecmp ("TCP", cb->protocol) != 0) + { + ERROR ("write_graphite plugin: Unknown protocol (%s)", + cb->protocol); + status = -1; + } + } else if (strcasecmp ("LogSendErrors", child->key) == 0) cf_util_get_boolean (child, &cb->log_send_errors); else if (strcasecmp ("Prefix", child->key) == 0) -- 2.11.0