You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 向指定节点发送一个 PING 或者 PONG 信息
void clusterSendPing(clusterLink link, int type) {
unsigned char buf[sizeof(clusterMsg)];
clusterMsg hdr = (clusterMsg) buf;
int gossipcount = 0, totlen;
/ freshnodes is the number of nodes we can still use to populate the
* gossip section of the ping packet. Basically we start with the nodes
* we have in memory minus two (ourself and the node we are sending the
* message to). Every time we add a node we decrement the counter, so when
* it will drop to <= zero we know there is no more gossip info we can
* send. */
// freshnodes 是用于发送 gossip 信息的计数器
// 每次发送一条信息时,程序将 freshnodes 的值减一
// 当 freshnodes 的数值小于等于 0 时,程序停止发送 gossip 信息
// freshnodes 的数量是节点目前的 nodes 表中的节点数量减去 2
// 这里的 2 指两个节点,一个是 myself 节点(也即是发送信息的这个节点)
// 另一个是接受 gossip 信息的节点
int freshnodes = dictSize(server.cluster->nodes)-2;
这里的while循环当中gossipcount的范围是[0,3),不应该是发送3个节点信息么?
另外,gossip = &(hdr->data.ping.gossip[gossipcount]);这个操作会不会污染后面的内存呢?毕竟gossip的数组大小是1.
// 向指定节点发送一个 PING 或者 PONG 信息
void clusterSendPing(clusterLink link, int type) {
unsigned char buf[sizeof(clusterMsg)];
clusterMsg hdr = (clusterMsg) buf;
int gossipcount = 0, totlen;
/ freshnodes is the number of nodes we can still use to populate the
* gossip section of the ping packet. Basically we start with the nodes
* we have in memory minus two (ourself and the node we are sending the
* message to). Every time we add a node we decrement the counter, so when
* it will drop to <= zero we know there is no more gossip info we can
* send. */
// freshnodes 是用于发送 gossip 信息的计数器
// 每次发送一条信息时,程序将 freshnodes 的值减一
// 当 freshnodes 的数值小于等于 0 时,程序停止发送 gossip 信息
// freshnodes 的数量是节点目前的 nodes 表中的节点数量减去 2
// 这里的 2 指两个节点,一个是 myself 节点(也即是发送信息的这个节点)
// 另一个是接受 gossip 信息的节点
int freshnodes = dictSize(server.cluster->nodes)-2;
}
The text was updated successfully, but these errors were encountered: