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
| 822 | * failure report from the same sender. 1 is returned if a new failure |
| 823 | * report is created. */ |
| 824 | int 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 |
no test coverage detected