1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Update the streamlist handler for slaves. Get the list of non-hidden mountpoints

from the stats engine instead of the mount or source list, as the stats are
populated by non-mount defined streams and mounts with active fallbacks.

svn path=/icecast/trunk/icecast/; revision=13500
This commit is contained in:
Karl Heyes 2007-08-09 23:36:29 +00:00
parent 3e8f2c39d4
commit 7248d653c0
3 changed files with 39 additions and 31 deletions

View File

@ -968,52 +968,24 @@ static void command_list_mounts(client_t *client, int response)
{
DEBUG0("List mounts request");
avl_tree_rlock (global.source_tree);
if (response == PLAINTEXT)
{
char *buf;
int remaining = PER_CLIENT_REFBUF_SIZE;
int ret;
ice_config_t *config = config_get_config ();
mount_proxy *mountinfo = config->mounts;
buf = client->refbuf->data;
ret = snprintf (buf, remaining,
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
while (mountinfo && ret > 0 && ret < remaining)
{
mount_proxy *current = mountinfo;
source_t *source;
mountinfo = mountinfo->next;
stats_get_streamlist (client->refbuf->data+ret, remaining-ret);
/* now check that a source is available */
source = source_find_mount (current->mountname);
if (source == NULL)
continue;
if (source->running == 0 && source->on_demand == 0)
continue;
if (source->hidden)
continue;
remaining -= ret;
buf += ret;
ret = snprintf (buf, remaining, "%s\n", current->mountname);
}
avl_tree_unlock (global.source_tree);
config_release_config();
/* handle last line */
if (ret > 0 && ret < remaining)
{
remaining -= ret;
buf += ret;
}
client->refbuf->len = PER_CLIENT_REFBUF_SIZE - remaining;
client->refbuf->len = strlen (client->refbuf->data);
fserve_add_client (client, NULL);
}
else
{
avl_tree_rlock (global.source_tree);
xmlDocPtr doc = admin_build_sourcelist(NULL);
avl_tree_unlock (global.source_tree);

View File

@ -1027,3 +1027,38 @@ static void _free_event(stats_event_t *event)
if (event->value) free(event->value);
free(event);
}
/* get a list of mountpoints that are in the stats but are not marked as hidden */
void stats_get_streamlist (char *buffer, size_t remaining)
{
avl_node *node;
/* now the stats for each source */
thread_mutex_lock (&_stats_mutex);
node = avl_get_first(_stats.source_tree);
while (node)
{
int ret;
stats_source_t *source = (stats_source_t *)node->key;
if (source->hidden == 0)
{
if (remaining <= strlen (source->source)+2)
{
WARN0 ("streamlist was truncated");
break;
}
ret = snprintf (buffer, remaining, "%s\r\n", source->source);
if (ret > 0)
{
buffer += ret;
remaining -= ret;
}
}
node = avl_get_next(node);
}
thread_mutex_unlock (&_stats_mutex);
}

View File

@ -74,6 +74,7 @@ void stats_initialize(void);
void stats_shutdown(void);
stats_t *stats_get_stats(void);
void stats_get_streamlist (char *buffer, size_t remaining);
void stats_event(const char *source, const char *name, const char *value);
void stats_event_args(const char *source, char *name, char *format, ...);