willemt / raft

C implementation of the Raft Consensus protocol, BSD licensed
Other
1.13k stars 271 forks source link

raft_send_appendentries_all logic #79

Open q96456 opened 6 years ago

q96456 commented 6 years ago

version 0.7.0 The code below,when "raft_send_appendentries" return not 0,the cycle will return. So if raft_node A is offline, B need send appendentries to A and C ,send A callback return -1,here return, C will not receive heatbeat?C will request vote?

int raft_send_appendentries_all(raft_servert* me) { raft_server_private_t me = (raft_server_private_t)me_; int i, e;

__log(me_, NULL, "%s:%d num node=%d",__FILE__, __LINE__, me->num_nodes);
me->timeout_elapsed = 0;
for (i = 0; i < me->num_nodes; i++)
{
    if (me->node == me->nodes[i] || !raft_node_is_active(me->nodes[i]))
        continue;

    e = raft_send_appendentries(me_, me->nodes[i]);
    if (0 != e)
        return e;
}

return 0;

}

freeekanayaka commented 6 years ago

This seems a valid point. Does upstream have an opinion?