diff --git a/src/admin.c b/src/admin.c index 0cd56a41..7f8d8a51 100644 --- a/src/admin.c +++ b/src/admin.c @@ -1186,12 +1186,13 @@ static void command_shoutcast_metadata(client_t *client, static void command_stats(client_t *client, source_t *source, admin_format_t response) { + unsigned int flags = (source) ? STATS_XML_FLAG_SHOW_HIDDEN|STATS_XML_FLAG_SHOW_LISTENERS : STATS_XML_FLAG_SHOW_HIDDEN; const char *mount = (source) ? source->mount : NULL; xmlDocPtr doc; ICECAST_LOG_DEBUG("Stats request, sending xml stats"); - doc = stats_get_xml(STATS_XML_FLAG_SHOW_HIDDEN, mount, client); + doc = stats_get_xml(flags, mount, client); admin_send_response(doc, client, response, STATS_HTML_REQUEST); xmlFreeDoc(doc); return; diff --git a/src/stats.c b/src/stats.c index e3f0a6c1..f527c49e 100644 --- a/src/stats.c +++ b/src/stats.c @@ -838,7 +838,8 @@ static inline void __add_authstack (auth_stack_t *stack, xmlNodePtr parent) { auth_stack_next(&stack); } } -static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, int hidden, client_t *client) { +static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, unsigned int flags, const char *show_mount, client_t *client) { + int hidden = flags & STATS_XML_FLAG_SHOW_HIDDEN ? 1 : 0; avl_node *avlnode; xmlNodePtr ret = NULL; ice_config_t *config; @@ -906,6 +907,9 @@ static xmlNodePtr _dump_stats_to_doc (xmlNodePtr root, const char *show_mount, i if (source_real->running) xmlNewTextChild(xmlnode, NULL, XMLSTR("content-type"), XMLSTR(source_real->format->contenttype)); + + if (flags & STATS_XML_FLAG_SHOW_LISTENERS) + admin_add_listeners_to_mount(source_real, xmlnode, client->mode); } avl_tree_unlock(global.source_tree); @@ -1087,7 +1091,6 @@ xmlDocPtr stats_get_xml(unsigned int flags, const char *show_mount, client_t *cl xmlDocPtr doc; xmlNodePtr node; xmlNodePtr modules; - source_t * source; doc = xmlNewDoc (XMLSTR("1.0")); node = xmlNewDocNode (doc, NULL, XMLSTR("icestats"), NULL); @@ -1096,14 +1099,7 @@ xmlDocPtr stats_get_xml(unsigned int flags, const char *show_mount, client_t *cl modules = module_container_get_modulelist_as_xml(global.modulecontainer); xmlAddChild(node, modules); - node = _dump_stats_to_doc(node, show_mount, flags & STATS_XML_FLAG_SHOW_HIDDEN ? 1 : 0, client); - - if (show_mount && node) { - avl_tree_rlock(global.source_tree); - source = source_find_mount_raw(show_mount); - admin_add_listeners_to_mount(source, node, client->mode); - avl_tree_unlock(global.source_tree); - } + node = _dump_stats_to_doc(node, flags, show_mount, client); return doc; } diff --git a/src/stats.h b/src/stats.h index 3b82d784..28363ccb 100644 --- a/src/stats.h +++ b/src/stats.h @@ -21,8 +21,9 @@ #include "icecasttypes.h" #include "refbuf.h" -#define STATS_XML_FLAG_NONE 0x0000U -#define STATS_XML_FLAG_SHOW_HIDDEN 0x0001U +#define STATS_XML_FLAG_NONE 0x0000U +#define STATS_XML_FLAG_SHOW_HIDDEN 0x0001U +#define STATS_XML_FLAG_SHOW_LISTENERS 0x0002U typedef struct _stats_node_tag {