summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 36e8719)
raw | patch | inline | side by side (parent: 36e8719)
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 dcede59983c00e38d281481b689c0b35d894e364..554ed931becf8a311f70d2b1de17102fc46961c5 100644 (file)
--- a/src/redis.c
+++ b/src/redis.c
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 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;
- 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)
}
}
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
.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
};
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);
- rh = redisConnectWithTimeout ((char *)rn->host, rn->port, tmout);
+ rh = redisConnectWithTimeout ((char *)rn->host, rn->port, rn->timeout);
if (rh == NULL)
{
ERROR ("redis plugin: unable to connect to node `%s' (%s:%d).", rn->name, rn->host, rn->port);