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

Function freeClusterNode

src/cluster.cpp:990–1012  ·  view source on GitHub ↗

Low level cleanup of the node structure. Only called by clusterDelNode(). */

Source from the content-addressed store, hash-verified

988
989/* Low level cleanup of the node structure. Only called by clusterDelNode(). */
990void freeClusterNode(clusterNode *n) {
991 sds nodename;
992 int j;
993
994 /* If the node has associated slaves, we have to set
995 * all the slaves->slaveof fields to NULL (unknown). */
996 for (j = 0; j < n->numslaves; j++)
997 n->slaves[j]->slaveof = NULL;
998
999 /* Remove this node from the list of slaves of its master. */
1000 if (nodeIsSlave(n) && n->slaveof) clusterNodeRemoveSlave(n->slaveof,n);
1001
1002 /* Unlink from the set of nodes. */
1003 nodename = sdsnewlen(n->name, CLUSTER_NAMELEN);
1004 serverAssert(dictDelete(g_pserver->cluster->nodes,nodename) == DICT_OK);
1005 sdsfree(nodename);
1006
1007 /* Release link and associated data structures. */
1008 if (n->link) freeClusterLink(n->link);
1009 listRelease(n->fail_reports);
1010 zfree(n->slaves);
1011 zfree(n);
1012}
1013
1014/* Add a node to the nodes hash table */
1015void clusterAddNode(clusterNode *node) {

Callers 1

clusterDelNodeFunction · 0.70

Calls 7

clusterNodeRemoveSlaveFunction · 0.85
sdsnewlenFunction · 0.85
sdsfreeFunction · 0.85
freeClusterLinkFunction · 0.85
listReleaseFunction · 0.85
zfreeFunction · 0.85
dictDeleteFunction · 0.70

Tested by

no test coverage detected