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

Function clusterNodeAddFailureReport

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

This function is called every time we get a failure report from a node. * The side effect is to populate the fail_reports list (or to update * the timestamp of an existing report). * * 'failing' is the node that is in failure state according to the * 'sender' node. * * The function returns 0 if it just updates a timestamp of an existing * failure report from the same sender. 1 is returned

Source from the content-addressed store, hash-verified

822 * failure report from the same sender. 1 is returned if a new failure
823 * report is created. */
824int clusterNodeAddFailureReport(clusterNode *failing, clusterNode *sender) {
825 list *l = failing->fail_reports;
826 listNode *ln;
827 listIter li;
828 clusterNodeFailReport *fr;
829
830 /* If a failure report from the same sender already exists, just update
831 * the timestamp. */
832 listRewind(l,&li);
833 while ((ln = listNext(&li)) != NULL) {
834 fr = ln->value;
835 if (fr->node == sender) {
836 fr->time = mstime();
837 return 0;
838 }
839 }
840
841 /* Otherwise create a new report. */
842 fr = zmalloc(sizeof(*fr));
843 fr->node = sender;
844 fr->time = mstime();
845 listAddNodeTail(l,fr);
846 return 1;
847}
848
849/* Remove failure reports that are too old, where too old means reasonably
850 * older than the global node timeout. Note that anyway for a node to be

Callers 1

Calls 5

listRewindFunction · 0.85
listNextFunction · 0.85
zmallocFunction · 0.85
listAddNodeTailFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected