summaryrefslogtreecommitdiff
path: root/src/sentinel.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-05-12 17:03:53 +0200
committerantirez <antirez@gmail.com>2015-05-12 17:03:53 +0200
commit0eb0b55ff0840c52527ff65f0fbcac84a6e0e231 (patch)
treefc764c7cc7b0e7914d7e4576c165c5ecc3ad4c60 /src/sentinel.c
parent9d5e2ed3922dd6f424a17c1d6712e672d4ee5fa0 (diff)
downloadredis-0eb0b55ff0840c52527ff65f0fbcac84a6e0e231.tar.gz
Sentinel: PING trigger improved
It's ok to ping as soon as the ping period has elapsed since we received the last PONG, but it's not good that we ping again if there is a pending ping... With this change we'll send a new ping if there is one pending only if two times the ping period elapsed since the ping which is still pending was sent.
Diffstat (limited to 'src/sentinel.c')
-rw-r--r--src/sentinel.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 916ab994c..40ffcce83 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -2498,7 +2498,10 @@ void sentinelSendPeriodicCommands(sentinelRedisInstance *ri) {
retval = redisAsyncCommand(ri->link->cc,
sentinelInfoReplyCallback, ri, "INFO");
if (retval == REDIS_OK) ri->link->pending_commands++;
- } else if ((now - ri->link->last_pong_time) > ping_period) {
+ } else if ((now - ri->link->last_pong_time) > ping_period &&
+ (ri->link->last_ping_time == 0 ||
+ now - ri->link->last_ping_time > ping_period*2))
+ {
/* Send PING to all the three kinds of instances. */
sentinelSendPing(ri);
} else if ((now - ri->last_pub_time) > SENTINEL_PUBLISH_PERIOD) {