Refactor show matrix to handle node IDs correctly.

Previously the code assumed repmgr node IDs to be sequential,
which is not guaranteed to be the case. With a non-sequential
list of node IDs, an incorrect node id would be displayed,
and memory accessed beyond the bounds of the matrix array.

The refactored code is considerably less elegant than the original
but will correctly handle a non-sequential sequence of node IDs.
This commit is contained in:
Ian Barwick
2016-09-29 18:51:55 +09:00
parent dc70e2d804
commit a2910eded9
2 changed files with 125 additions and 45 deletions

View File

@@ -165,5 +165,32 @@ typedef struct
t_configfile_info **files;
} t_configfile_list;
typedef struct
{
int node_id;
int node_status;
} t_node_status_rec;
typedef struct
{
int node_id;
char node_name[MAXLEN];
t_node_status_rec **node_status_list;
} t_node_status_matrix_rec;
typedef struct
{
int length;
t_node_status_matrix_rec **matrix_list;
} t_node_status_matrix;
typedef struct
{
int node_id;
t_node_status_matrix **node_matrix;
} t_node_status_cube;
#define T_CONFIGFILE_LIST_INITIALIZER { 0, 0, NULL }
#endif