From 241c8f0895323d7a807f64ca118455ae0e966664 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Fri, 25 Feb 2022 12:53:33 +0000 Subject: [PATCH] Feature: Added warning about legacy sources on dashboard --- src/admin.c | 6 ++++++ src/format_mp3.c | 8 ++++++++ src/global.c | 1 + src/global.h | 1 + 4 files changed, 16 insertions(+) diff --git a/src/admin.c b/src/admin.c index 2078ffb5..66b38298 100644 --- a/src/admin.c +++ b/src/admin.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1493,6 +1494,7 @@ static void command_dashboard (client_t *client, source_t *source, adm int has_sources; int has_many_clients; int has_too_many_clients; + bool has_legacy_sources; resource = reportxml_node_new(REPORTXML_NODE_TYPE_RESOURCE, NULL, NULL, NULL); @@ -1517,6 +1519,7 @@ static void command_dashboard (client_t *client, source_t *source, adm has_sources = global.sources > 0; has_many_clients = global.clients > ((75 * config->client_limit) / 100); has_too_many_clients = global.clients > ((90 * config->client_limit) / 100); + has_legacy_sources = global.sources_legacy > 0; global_unlock(); reportxml_node_add_child(resource, node); refobject_unref(node); @@ -1545,6 +1548,9 @@ static void command_dashboard (client_t *client, source_t *source, adm if (!has_sources) __reportxml_add_maintenance(reportnode, config->reportxml_db, "f68dd8a3-22b1-4118-aba6-b039f2c5b51e", "info", "Currently no sources are connected to this server.", NULL); + if (has_legacy_sources) + __reportxml_add_maintenance(reportnode, config->reportxml_db, "a3a51986-3bba-42b9-ad5c-d9ecc9967320", "warning", "Legacy sources are connected. See mount list for details.", NULL); + if (has_too_many_clients) { __reportxml_add_maintenance(reportnode, config->reportxml_db, "08676614-50b4-4ea7-ba99-7c2ffcecf705", "warning", "More than 90% of the server's configured maximum clients are connected", NULL); } else if (has_many_clients) { diff --git a/src/format_mp3.c b/src/format_mp3.c index 1fcce4d8..8a55a58a 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -30,6 +30,7 @@ # include #endif +#include "global.h" #include "refbuf.h" #include "source.h" #include "client.h" @@ -119,6 +120,9 @@ int format_mp3_get_plugin(source_t *source) source->format = plugin; thread_mutex_create(&state->url_lock); + /* we are in global locked state here, locked by connection_complete_source(). */ + global.sources_legacy++; + return 0; } @@ -488,6 +492,10 @@ static void format_mp3_free_plugin(format_plugin_t *self) free(state); vorbis_comment_clear(&self->vc); free(self); + + global_lock(); + global.sources_legacy--; + global_unlock(); } diff --git a/src/global.c b/src/global.c index 2a2fec6f..1664c7f8 100644 --- a/src/global.c +++ b/src/global.c @@ -38,6 +38,7 @@ void global_initialize(void) global.running = 0; global.clients = 0; global.sources = 0; + global.sources_legacy = 0; global.source_tree = avl_tree_new(source_compare_sources, NULL); global.modulecontainer = refobject_new(module_container_t); thread_mutex_create(&_global_mutex); diff --git a/src/global.h b/src/global.h index 1415d1e9..4b13c0ec 100644 --- a/src/global.h +++ b/src/global.h @@ -32,6 +32,7 @@ typedef struct ice_global_tag int running; int sources; + int sources_legacy; int clients; int schedule_config_reread;