From dd36f18c76e7793567598fc168e54b41e06d4a61 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Mon, 4 Aug 2014 13:13:12 -0400 Subject: [PATCH] Sentinel: Abort Hello quicker if not connected We can save a little work by aborting when we enter the function if we're disconnected. --- src/sentinel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sentinel.c b/src/sentinel.c index 603cdd40..d26705c2 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -2216,9 +2216,10 @@ int sentinelSendHello(sentinelRedisInstance *ri) { sentinelRedisInstance *master = (ri->flags & SRI_MASTER) ? ri : ri->master; sentinelAddr *master_addr = sentinelGetCurrentMasterAddress(master); + if (ri->flags & SRI_DISCONNECTED) return REDIS_ERR; + /* Try to obtain our own IP address. */ if (anetSockName(ri->cc->c.fd,ip,sizeof(ip),NULL) == -1) return REDIS_ERR; - if (ri->flags & SRI_DISCONNECTED) return REDIS_ERR; /* Format and send the Hello message. */ snprintf(payload,sizeof(payload), -- GitLab