summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-04-24 15:19:06 -0400
committerantirez <antirez@gmail.com>2014-06-23 11:54:45 +0200
commita2632f2692ab966d999052fed946e9dc758b9bcb (patch)
tree5c279094837c7f66c4183542b3a0c6364d169814
parentba472111d313357c232e8e180f3e64a357bb37c8 (diff)
downloadredis-a2632f2692ab966d999052fed946e9dc758b9bcb.tar.gz
Add REDIS_BIND_ADDR access macro
We need to access (bindaddr[0] || NULL) in a few places, so centralize access with a nice macro.
-rw-r--r--src/cluster.c3
-rw-r--r--src/redis.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 4ed559376..20da6d519 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -2794,8 +2794,7 @@ void clusterCron(void) {
clusterLink *link;
fd = anetTcpNonBlockBindConnect(server.neterr, node->ip,
- node->port+REDIS_CLUSTER_PORT_INCR,
- server.bindaddr_count ? server.bindaddr[0] : NULL);
+ node->port+REDIS_CLUSTER_PORT_INCR, REDIS_BIND_ADDR);
if (fd == -1) {
redisLog(REDIS_DEBUG, "Unable to connect to "
"Cluster Node [%s]:%d -> %s", node->ip,
diff --git a/src/redis.h b/src/redis.h
index 02def27d7..b39206f93 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -367,6 +367,9 @@
#define REDIS_NOTIFY_EVICTED (1<<9) /* e */
#define REDIS_NOTIFY_ALL (REDIS_NOTIFY_GENERIC | REDIS_NOTIFY_STRING | REDIS_NOTIFY_LIST | REDIS_NOTIFY_SET | REDIS_NOTIFY_HASH | REDIS_NOTIFY_ZSET | REDIS_NOTIFY_EXPIRED | REDIS_NOTIFY_EVICTED) /* A */
+/* Get the first bind addr or NULL */
+#define REDIS_BIND_ADDR (server.bindaddr_count ? server.bindaddr[0] : NULL)
+
/* Using the following macro you can run code inside serverCron() with the
* specified period, specified in milliseconds.
* The actual resolution depends on server.hz. */