提交 832a2980 编写于 作者: A antirez

Cluster: fixed data_age computation / check integer overflow.

上级 26923391
...@@ -2318,9 +2318,10 @@ void clusterHandleSlaveFailover(void) { ...@@ -2318,9 +2318,10 @@ void clusterHandleSlaveFailover(void) {
/* Set data_age to the number of seconds we are disconnected from /* Set data_age to the number of seconds we are disconnected from
* the master. */ * the master. */
if (server.repl_state == REDIS_REPL_CONNECTED) { if (server.repl_state == REDIS_REPL_CONNECTED) {
data_age = (server.unixtime - server.master->lastinteraction) * 1000; data_age = (mstime_t)(server.unixtime - server.master->lastinteraction)
* 1000;
} else { } else {
data_age = (server.unixtime - server.repl_down_since) * 1000; data_age = (mstime_t)(server.unixtime - server.repl_down_since) * 1000;
} }
/* Remove the node timeout from the data age as it is fine that we are /* Remove the node timeout from the data age as it is fine that we are
...@@ -2335,7 +2336,7 @@ void clusterHandleSlaveFailover(void) { ...@@ -2335,7 +2336,7 @@ void clusterHandleSlaveFailover(void) {
* *
* Check bypassed for manual failovers. */ * Check bypassed for manual failovers. */
if (data_age > if (data_age >
(server.repl_ping_slave_period * 1000) + ((mstime_t)server.repl_ping_slave_period * 1000) +
(server.cluster_node_timeout * REDIS_CLUSTER_SLAVE_VALIDITY_MULT)) (server.cluster_node_timeout * REDIS_CLUSTER_SLAVE_VALIDITY_MULT))
{ {
if (!manual_failover) return; if (!manual_failover) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册