diff --git a/include/crm/common/output.h b/include/crm/common/output.h index 6188f19..939972c 100644 --- a/include/crm/common/output.h +++ b/include/crm/common/output.h @@ -703,15 +703,14 @@ pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, con * the following code would generate the tag "": * * \code - * pcmk__html_add_header(parent, "meta", "http-equiv", "refresh", "content", "19", NULL); + * pcmk__html_add_header("meta", "http-equiv", "refresh", "content", "19", NULL); * \endcode * - * \param[in,out] parent The node that will be the parent of the new node. * \param[in] name The HTML tag for the new node. * \param[in] ... A NULL-terminated key/value list of attributes. */ void -pcmk__html_add_header(xmlNodePtr parent, const char *name, ...) +pcmk__html_add_header(const char *name, ...) G_GNUC_NULL_TERMINATED; #ifdef __cplusplus diff --git a/lib/common/output_html.c b/lib/common/output_html.c index 6e21031..259e412 100644 --- a/lib/common/output_html.c +++ b/lib/common/output_html.c @@ -139,7 +139,7 @@ finish_reset_common(pcmk__output_t *out, crm_exit_t exit_status, bool print) { /* Add any extra header nodes the caller might have created. */ for (int i = 0; i < g_slist_length(extra_headers); i++) { - xmlAddChild(head_node, g_slist_nth_data(extra_headers, i)); + xmlAddChild(head_node, xmlCopyNode(g_slist_nth_data(extra_headers, i), 1)); } /* Stylesheets are included two different ways. The first is via a built-in @@ -185,6 +185,8 @@ html_finish(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy if (copy_dest != NULL) { *copy_dest = copy_xml(priv->root); } + + g_slist_free_full(extra_headers, (GDestroyNotify) xmlFreeNode); } static void @@ -199,7 +201,6 @@ html_reset(pcmk__output_t *out) { } html_free_priv(out); - g_slist_free_full(extra_headers, (GDestroyNotify) xmlFreeNode); html_init(out); } @@ -412,7 +413,7 @@ pcmk__output_create_html_node(pcmk__output_t *out, const char *element_name, con } void -pcmk__html_add_header(xmlNodePtr parent, const char *name, ...) { +pcmk__html_add_header(const char *name, ...) { htmlNodePtr header_node; va_list ap; diff --git a/tools/crm_mon.c b/tools/crm_mon.c index 7036c3f..2fe9fb4 100644 --- a/tools/crm_mon.c +++ b/tools/crm_mon.c @@ -1350,6 +1350,12 @@ main(int argc, char **argv) options.mon_ops |= mon_op_print_timing | mon_op_inactive_resources; } + if ((output_format == mon_output_html || output_format == mon_output_cgi) && + out->dest != stdout) { + pcmk__html_add_header("meta", "http-equiv", "refresh", "content", + crm_itoa(options.reconnect_msec/1000), NULL); + } + crm_info("Starting %s", crm_system_name); if (cib) { @@ -2110,15 +2116,6 @@ clean_up_connections(void) } } -static void -handle_html_output(crm_exit_t exit_code) { - xmlNodePtr html = NULL; - - pcmk__html_add_header(html, "meta", "http-equiv", "refresh", "content", - crm_itoa(options.reconnect_msec/1000), NULL); - out->finish(out, exit_code, true, (void **) &html); -} - /* * De-init ncurses, disconnect from the CIB manager, disconnect fencing, * deallocate memory and show usage-message if requested. @@ -2192,16 +2189,7 @@ clean_up(crm_exit_t exit_code) CRM_ASSERT(out->dest != NULL); } - switch (output_format) { - case mon_output_cgi: - case mon_output_html: - handle_html_output(exit_code); - break; - - default: - out->finish(out, exit_code, true, NULL); - break; - } + out->finish(out, exit_code, true, NULL); pcmk__output_free(out); pcmk__unregister_formats();