From 13dfaffadcf04eeed55f0934b77fcfa29aa5b7a7 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Tue, 24 Aug 2004 00:02:40 +0000 Subject: [PATCH] make inactive on-demand relays show up on xsl pages svn path=/icecast/branches/kh/icecast/; revision=7620 --- src/source.c | 49 ++++++++++++++++++++++++++----------------------- src/stats.c | 4 ++-- src/stats.h | 4 ++-- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/source.c b/src/source.c index 3319911f..d91f905e 100644 --- a/src/source.c +++ b/src/source.c @@ -77,6 +77,10 @@ source_t *source_reserve (const char *mount) do { + unsigned int listen_url_size; + char *listenurl; + ice_config_t *config; + avl_tree_wlock (global.source_tree); src = source_find_mount_raw (mount); if (src) @@ -99,6 +103,25 @@ source_t *source_reserve (const char *mount) avl_insert (global.source_tree, src); + config = config_get_config(); + + /* 6 for max size of port */ + listen_url_size = strlen("http://") + strlen(config->hostname) + + strlen(":") + 6 + strlen(mount) + 1; + + listenurl = malloc (listen_url_size); + if (listenurl) + { + snprintf (listenurl, listen_url_size, "http://%s:%d%s", + config->hostname, config->port, mount); + + stats_event (mount, "listenurl", listenurl); + + free(listenurl); + } + config_release_config(); + stats_event (mount, "listeners", "0"); + } while (0); avl_tree_unlock (global.source_tree); @@ -284,6 +307,8 @@ void source_free_source (source_t *source) avl_tree_wlock (global.source_tree); avl_delete (global.source_tree, source, NULL); avl_tree_unlock (global.source_tree); + stats_event (source->mount, "listeners", NULL); + stats_event (source->mount, NULL, NULL); /* There should be no listeners on this mount */ if (source->active_clients) @@ -651,27 +676,7 @@ static void get_next_buffer (source_t *source) static void source_init (source_t *source) { - ice_config_t *config = config_get_config(); - char *listenurl, *str = NULL; - int listen_url_size; - - /* 6 for max size of port */ - listen_url_size = strlen("http://") + strlen(config->hostname) + - strlen(":") + 6 + strlen(source->mount) + 1; - - listenurl = malloc (listen_url_size); - if (listenurl) - { - snprintf (listenurl, listen_url_size, "http://%s:%d%s", - config->hostname, config->port, source->mount); - config_release_config(); - - stats_event (source->mount, "listenurl", listenurl); - - free(listenurl); - } - else - config_release_config(); + char *str = NULL; thread_mutex_lock (&source->lock); if (source->yp_prevent == 0) @@ -728,7 +733,6 @@ static void source_init (source_t *source) source->listeners = 0; stats_event_inc (NULL, "sources"); stats_event_inc (NULL, "source_total_connections"); - stats_event (source->mount, "listeners", "0"); stats_event (source->mount, "type", source->format->format_description); sock_set_blocking (source->con->sock, SOCK_NONBLOCK); @@ -1091,7 +1095,6 @@ static void source_shutdown (source_t *source) /* delete this sources stats */ stats_event_dec (NULL, "sources"); - stats_event (source->mount, "listeners", NULL); /* we don't remove the source from the tree here, it may be a relay and therefore reserved */ diff --git a/src/stats.c b/src/stats.c index b8652cab..afcb6ddd 100644 --- a/src/stats.c +++ b/src/stats.c @@ -155,7 +155,7 @@ stats_t *stats_get_stats() return NULL; } -void stats_event(char *source, char *name, char *value) +void stats_event(const char *source, char *name, char *value) { stats_event_t *node; stats_event_t *event; @@ -183,7 +183,7 @@ void stats_event(char *source, char *name, char *value) thread_mutex_unlock(&_global_event_mutex); } -void stats_event_args(char *source, char *name, char *format, ...) +void stats_event_args(const char *source, char *name, char *format, ...) { char buf[1024]; va_list val; diff --git a/src/stats.h b/src/stats.h index 894af3df..c05c1768 100644 --- a/src/stats.h +++ b/src/stats.h @@ -77,8 +77,8 @@ void stats_shutdown(); stats_t *stats_get_stats(); -void stats_event(char *source, char *name, char *value); -void stats_event_args(char *source, char *name, char *format, ...); +void stats_event(const char *source, char *name, char *value); +void stats_event_args(const char *source, char *name, char *format, ...); void stats_event_inc(char *source, char *name); void stats_event_add(char *source, char *name, unsigned long value); void stats_event_dec(char *source, char *name);