mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Cluster: claim ping_sent time even if we can't connect.
This fixes a potential bug that was never observed in practice since what happens is that the asynchronous connect returns ok (to fail later, calling the handler) every time, so a ping is queued, and sent_ping happens to always be populated. Howver technically connect(2) with a non blocking socket may return an error synchronously, so before this fix the code was not correct.
This commit is contained in:
parent
c89afc8e5d
commit
2374496799
@ -2825,6 +2825,12 @@ void clusterCron(void) {
|
||||
fd = anetTcpNonBlockBindConnect(server.neterr, node->ip,
|
||||
node->port+REDIS_CLUSTER_PORT_INCR, REDIS_BIND_ADDR);
|
||||
if (fd == -1) {
|
||||
/* We got a synchronous error from connect before
|
||||
* clusterSendPing() had a chance to be called.
|
||||
* If node->ping_sent is zero, failure detection can't work,
|
||||
* so we claim we actually sent a ping now (that will
|
||||
* be really sent as soon as the link is obtained). */
|
||||
if (node->ping_sent == 0) node->ping_sent = mstime();
|
||||
redisLog(REDIS_DEBUG, "Unable to connect to "
|
||||
"Cluster Node [%s]:%d -> %s", node->ip,
|
||||
node->port+REDIS_CLUSTER_PORT_INCR,
|
||||
|
Loading…
Reference in New Issue
Block a user