From d41b166d16eaed2f10cc1b42cc443e32ead9843e Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Sun, 17 Jun 2018 19:09:21 +0700 Subject: [PATCH] write_redis plugin: Fixed bug of Timeout option Documentation states what Timeout is set in milliseconds. Code was fixed to match documentation. --- src/write_redis.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/write_redis.c b/src/write_redis.c index c17654b4..72cb5946 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -184,8 +184,8 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ return ENOMEM; node->host = NULL; node->port = 0; - node->timeout.tv_sec = 0; - node->timeout.tv_usec = 1000; + node->timeout.tv_sec = 1; + node->timeout.tv_usec = 0; node->conn = NULL; node->prefix = NULL; node->database = 0; @@ -213,8 +213,11 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ } } else if (strcasecmp("Timeout", child->key) == 0) { status = cf_util_get_int(child, &timeout); - if (status == 0) - node->timeout.tv_usec = timeout; + if (status == 0) { + node->timeout.tv_usec = timeout * 1000; + node->timeout.tv_sec = node->timeout.tv_usec / 1000000L; + node->timeout.tv_usec %= 1000000L; + } } else if (strcasecmp("Prefix", child->key) == 0) { status = cf_util_get_string(child, &node->prefix); } else if (strcasecmp("Database", child->key) == 0) { -- 2.11.0