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
| 861 | * failure report from the same sender. 1 is returned if a new failure |
| 862 | * report is created. */ |
| 863 | int clusterNodeAddFailureReport(clusterNode *failing, clusterNode *sender) { |
| 864 | list *l = failing->fail_reports; |
| 865 | listNode *ln; |
| 866 | listIter li; |
| 867 | clusterNodeFailReport *fr; |
| 868 | |
| 869 | /* If a failure report from the same sender already exists, just update |
| 870 | * the timestamp. */ |
| 871 | listRewind(l,&li); |
| 872 | while ((ln = listNext(&li)) != NULL) { |
| 873 | fr = (clusterNodeFailReport*)ln->value; |
| 874 | if (fr->node == sender) { |
| 875 | fr->time = mstime(); |
| 876 | return 0; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | /* Otherwise create a new report. */ |
| 881 | fr = (clusterNodeFailReport*)zmalloc(sizeof(*fr), MALLOC_LOCAL); |
| 882 | fr->node = sender; |
| 883 | fr->time = mstime(); |
| 884 | listAddNodeTail(l,fr); |
| 885 | return 1; |
| 886 | } |
| 887 | |
| 888 | /* Remove failure reports that are too old, where too old means reasonably |
| 889 | * older than the global node timeout. Note that anyway for a node to be |
no test coverage detected