From: Paul Sadauskas Date: Sat, 20 Jun 2009 21:38:28 +0000 (-0600) Subject: Fix a bug with recording of port X-Git-Tag: collectd-4.8.0~76^2~9 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=895287495fcae8c8f496a398384ce40576f81acd;p=collectd.git Fix a bug with recording of port Port was getting written to plugin_instance as "1978.00000", because apparently that's the value returned by the config. --- diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c index 73a065e1..b59315cb 100644 --- a/src/tokyotyrant.c +++ b/src/tokyotyrant.c @@ -34,10 +34,8 @@ static const char *config_keys[] = static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); static char *host = NULL; - -/* int is for opening connection, string is for plugin_instance */ -static char *port_str = NULL; static int port; +static char port_str[5]; static int tt_config (const char *key, const char *value) { @@ -49,17 +47,13 @@ static int tt_config (const char *key, const char *value) } else if (strcasecmp ("Port", key) == 0) { - if (port_str != NULL) - free (port_str); - port_str = strdup(value); - port = atoi(value); - if ((port < 0) || (port > 65535)) { ERROR ("tokyotyrant plugin: error: Port %s out of range", value); return (-1); } + ssnprintf(port_str, 5, "%i", port); } else {