MCPcopy Create free account
hub / github.com/F-Stack/f-stack / freeClusterNode

Function freeClusterNode

app/redis-6.2.6/src/cluster.c:951–973  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

949
950/* Low level cleanup of the node structure. Only called by clusterDelNode(). */
951void freeClusterNode(clusterNode *n) {
952 sds nodename;
953 int j;
954
955 /* If the node has associated slaves, we have to set
956 * all the slaves->slaveof fields to NULL (unknown). */
957 for (j = 0; j < n->numslaves; j++)
958 n->slaves[j]->slaveof = NULL;
959
960 /* Remove this node from the list of slaves of its master. */
961 if (nodeIsSlave(n) && n->slaveof) clusterNodeRemoveSlave(n->slaveof,n);
962
963 /* Unlink from the set of nodes. */
964 nodename = sdsnewlen(n->name, CLUSTER_NAMELEN);
965 serverAssert(dictDelete(server.cluster->nodes,nodename) == DICT_OK);
966 sdsfree(nodename);
967
968 /* Release link and associated data structures. */
969 if (n->link) freeClusterLink(n->link);
970 listRelease(n->fail_reports);
971 zfree(n->slaves);
972 zfree(n);
973}
974
975/* Add a node to the nodes hash table */
976void 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
dictDeleteFunction · 0.70
zfreeFunction · 0.70

Tested by

no test coverage detected