projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
36e8719
)
use timeval. keep timeout in milliseconds for backwards compatibility.
author
Victor Seva
<linuxmaniac@torreviejawireless.org>
Thu, 14 Nov 2013 12:37:08 +0000
(13:37 +0100)
committer
Marc Fournier
<marc.fournier@camptocamp.com>
Fri, 7 Nov 2014 21:44:56 +0000
(22:44 +0100)
src/redis.c
patch
|
blob
|
history
diff --git
a/src/redis.c
b/src/redis.c
index
dcede59
..
554ed93
100644
(file)
--- a/
src/redis.c
+++ b/
src/redis.c
@@
-60,7
+60,7
@@
struct redis_node_s
char host[HOST_NAME_MAX];
char passwd[MAX_REDIS_PASSWD_LENGTH];
int port;
char host[HOST_NAME_MAX];
char passwd[MAX_REDIS_PASSWD_LENGTH];
int port;
-
int
timeout;
+
struct timeval
timeout;
redis_node_t *next;
};
redis_node_t *next;
};
@@
-115,11
+115,12
@@
static int redis_config_node (oconfig_item_t *ci) /* {{{ */
redis_node_t rn;
int i;
int status;
redis_node_t rn;
int i;
int status;
+ int timeout;
memset (&rn, 0, sizeof (rn));
sstrncpy (rn.host, REDIS_DEF_HOST, sizeof (rn.host));
rn.port = REDIS_DEF_PORT;
memset (&rn, 0, sizeof (rn));
sstrncpy (rn.host, REDIS_DEF_HOST, sizeof (rn.host));
rn.port = REDIS_DEF_PORT;
- rn.timeout = REDIS_DEF_TIMEOUT;
+ rn.timeout
.tv_usec
= REDIS_DEF_TIMEOUT;
status = cf_util_get_string_buffer (ci, rn.name, sizeof (rn.name));
if (status != 0)
status = cf_util_get_string_buffer (ci, rn.name, sizeof (rn.name));
if (status != 0)
@@
-141,7
+142,10
@@
static int redis_config_node (oconfig_item_t *ci) /* {{{ */
}
}
else if (strcasecmp ("Timeout", option->key) == 0)
}
}
else if (strcasecmp ("Timeout", option->key) == 0)
- status = cf_util_get_int (option, &rn.timeout);
+ {
+ status = cf_util_get_int (option, &timeout);
+ if (status == 0) rn.timeout.tv_usec = timeout;
+ }
else if (strcasecmp ("Password", option->key) == 0)
status = cf_util_get_string_buffer (option, rn.passwd, sizeof (rn.passwd));
else
else if (strcasecmp ("Password", option->key) == 0)
status = cf_util_get_string_buffer (option, rn.passwd, sizeof (rn.passwd));
else
@@
-213,7
+217,8
@@
static int redis_init (void) /* {{{ */
.name = "default",
.host = REDIS_DEF_HOST,
.port = REDIS_DEF_PORT,
.name = "default",
.host = REDIS_DEF_HOST,
.port = REDIS_DEF_PORT,
- .timeout = REDIS_DEF_TIMEOUT,
+ .timeout.tv_sec = 0,
+ .timeout.tv_usec = REDIS_DEF_TIMEOUT,
.next = NULL
};
.next = NULL
};
@@
-259,14
+264,9
@@
static int redis_read (void) /* {{{ */
redisContext *rh;
redisReply *rr;
redisContext *rh;
redisReply *rr;
- struct timeval tmout;
-
- tmout.tv_sec = rn->timeout;
- tmout.tv_usec = 0;
-
DEBUG ("redis plugin: querying info from node `%s' (%s:%d).", rn->name, rn->host, rn->port);
DEBUG ("redis plugin: querying info from node `%s' (%s:%d).", rn->name, rn->host, rn->port);
- rh = redisConnectWithTimeout ((char *)rn->host, rn->port,
tm
out);
+ rh = redisConnectWithTimeout ((char *)rn->host, rn->port,
rn->time
out);
if (rh == NULL)
{
ERROR ("redis plugin: unable to connect to node `%s' (%s:%d).", rn->name, rn->host, rn->port);
if (rh == NULL)
{
ERROR ("redis plugin: unable to connect to node `%s' (%s:%d).", rn->name, rn->host, rn->port);