Reviewed-by: Steven Dake <sdake@xxxxxxxxxx> On 01/17/2012 06:38 AM, Fabio M. Di Nitto wrote: > From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> > > make display_nodes code common with show_nodes > > Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> > --- > tools/corosync-quorumtool.c | 59 ++++++++++++++++++++++--------------------- > 1 files changed, 30 insertions(+), 29 deletions(-) > > diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c > index b71654c..45c0e32 100644 > --- a/tools/corosync-quorumtool.c > +++ b/tools/corosync-quorumtool.c > @@ -279,6 +279,34 @@ static void quorum_notification_fn( > } > } > > +static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name_format) > +{ > + int i; > + > + if (v_handle) { > + printf("Nodeid Votes Name\n"); > + } else { > + printf("Nodeid Name\n"); > + } > + > + for (i=0; i < g_view_list_entries; i++) { > + if (nodeid_format == NODEID_FORMAT_DECIMAL) { > + printf("%4u ", g_view_list[i]); > + } else { > + printf("0x%04x ", g_view_list[i]); > + } > + if (v_handle) { > + printf("%3d %s\n", get_votes(g_view_list[i]), node_name(g_view_list[i], name_format)); > + } else { > + printf("%s\n", node_name(g_view_list[i], name_format)); > + } > + } > + if (g_view_list_entries) { > + free(g_view_list); > + g_view_list = NULL; > + } > +} > + > static int display_quorum_data(int is_quorate, int loop) > { > struct votequorum_info info; > @@ -395,6 +423,7 @@ static int monitor_status(nodeid_format_t nodeid_format, name_format_t name_form > time(&t); > printf("date: %s", ctime((const time_t *)&t)); > err = display_quorum_data(g_quorate, loop); > + display_nodes_data(nodeid_format, name_format); > printf("\n"); > loop = 1; > if (err != CS_OK) { > @@ -409,7 +438,6 @@ quorum_err: > > static int show_nodes(nodeid_format_t nodeid_format, name_format_t name_format) > { > - int i; > int err; > int result = EXIT_FAILURE; > > @@ -424,34 +452,7 @@ static int show_nodes(nodeid_format_t nodeid_format, name_format_t name_format) > quorum_dispatch(q_handle, CS_DISPATCH_ONE); > } > > - quorum_finalize(q_handle); > - q_handle = 0; > - > - err = corosync_cfg_initialize(&c_handle, &c_callbacks); > - if (err != CS_OK) { > - fprintf(stderr, "Cannot initialise CFG service\n"); > - c_handle = 0; > - goto err_exit; > - } > - > - if (v_handle) { > - printf("Nodeid Votes Name\n"); > - } else { > - printf("Nodeid Name\n"); > - } > - > - for (i=0; i < g_view_list_entries; i++) { > - if (nodeid_format == NODEID_FORMAT_DECIMAL) { > - printf("%4u ", g_view_list[i]); > - } else { > - printf("0x%04x ", g_view_list[i]); > - } > - if (v_handle) { > - printf("%3d %s\n", get_votes(g_view_list[i]), node_name(g_view_list[i], name_format)); > - } else { > - printf("%s\n", node_name(g_view_list[i], name_format)); > - } > - } > + display_nodes_data(nodeid_format, name_format); > > result = EXIT_SUCCESS; > err_exit: _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss