MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterBroadcastMessage

Function clusterBroadcastMessage

src/cluster.cpp:2474–2488  ·  view source on GitHub ↗

Send a message to all the nodes that are part of the cluster having * a connected link. * * It is guaranteed that this function will never have as a side effect * some node->link to be invalidated, so it is safe to call this function * from event handlers that will do stuff with node links later. */

Source from the content-addressed store, hash-verified

2472 * some node->link to be invalidated, so it is safe to call this function
2473 * from event handlers that will do stuff with node links later. */
2474void clusterBroadcastMessage(void *buf, size_t len) {
2475 dictIterator *di;
2476 dictEntry *de;
2477
2478 di = dictGetSafeIterator(g_pserver->cluster->nodes);
2479 while((de = dictNext(di)) != NULL) {
2480 clusterNode *node = (clusterNode*)dictGetVal(de);
2481
2482 if (!node->link) continue;
2483 if (node->flags & (CLUSTER_NODE_MYSELF|CLUSTER_NODE_HANDSHAKE))
2484 continue;
2485 clusterSendMessage(node->link,(unsigned char*)buf,len);
2486 }
2487 dictReleaseIterator(di);
2488}
2489
2490/* Build the message header. hdr must point to a buffer at least
2491 * sizeof(clusterMsg) in bytes. */

Callers 4

clusterSendPublishFunction · 0.85
clusterSendFailFunction · 0.85
clusterSendModuleFunction · 0.85

Calls 4

dictGetSafeIteratorFunction · 0.85
clusterSendMessageFunction · 0.85
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected