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

Allow any number of mountpoints to be returned for streamlist. You would

need a large number of mountpoints to trigger a truncation.  Allow file
serving thread to process a list of blocks for sending back to
the client. Then build the block list in the stats engine for returning.

svn path=/icecast/trunk/icecast/; revision=14812
This commit is contained in:
Karl Heyes 2008-04-29 04:50:23 +00:00
parent 2822e350bb
commit cbb7643b43
4 changed files with 33 additions and 23 deletions

View File

@ -995,17 +995,12 @@ static void command_list_mounts(client_t *client, int response)
if (response == PLAINTEXT)
{
char *buf;
int remaining = PER_CLIENT_REFBUF_SIZE;
int ret;
buf = client->refbuf->data;
ret = snprintf (buf, remaining,
snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
stats_get_streamlist (client->refbuf->data+ret, remaining-ret);
client->refbuf->len = strlen (client->refbuf->data);
client->respcode = 200;
client->refbuf->next = stats_get_streams ();
fserve_add_client (client, NULL);
}
else

View File

@ -262,13 +262,19 @@ static void *fserv_thread_function(void *arg)
bytes = 0;
if (bytes == 0)
{
fserve_t *to_go = fclient;
fclient = fclient->next;
*trail = fclient;
fserve_client_destroy (to_go);
fserve_clients--;
client_tree_changed = 1;
continue;
if (refbuf->next == NULL)
{
fserve_t *to_go = fclient;
fclient = fclient->next;
*trail = fclient;
fserve_client_destroy (to_go);
fserve_clients--;
client_tree_changed = 1;
continue;
}
client_set_queue (client, refbuf->next);
refbuf = client->refbuf;
bytes = refbuf->len;
}
refbuf->len = (unsigned int)bytes;
client->pos = 0;

View File

@ -1096,10 +1096,13 @@ static void _free_event(stats_event_t *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)
refbuf_t *stats_get_streams (void)
{
#define STREAMLIST_BLKSIZE 4096
avl_node *node;
int remaining = STREAMLIST_BLKSIZE;
refbuf_t *start = refbuf_new (remaining), *cur = start;
char *buffer = cur->data;
/* now the stats for each source */
thread_mutex_lock (&_stats_mutex);
@ -1111,10 +1114,13 @@ void stats_get_streamlist (char *buffer, size_t remaining)
if (source->hidden == 0)
{
if (remaining <= strlen (source->source)+2)
if (remaining <= strlen (source->source) + 3)
{
WARN0 ("streamlist was truncated");
break;
cur->len = STREAMLIST_BLKSIZE - remaining;
cur->next = refbuf_new (STREAMLIST_BLKSIZE);
remaining = STREAMLIST_BLKSIZE;
cur = cur->next;
buffer = cur->data;
}
ret = snprintf (buffer, remaining, "%s\r\n", source->source);
if (ret > 0)
@ -1123,12 +1129,15 @@ void stats_get_streamlist (char *buffer, size_t remaining)
remaining -= ret;
}
}
node = avl_get_next(node);
}
thread_mutex_unlock (&_stats_mutex);
cur->len = STREAMLIST_BLKSIZE - remaining;
return start;
}
/* This removes any source stats from virtual mountpoints, ie mountpoints
* where no source_t exists. This function requires the global sources lock
* to be held before calling.

View File

@ -76,7 +76,7 @@ void stats_shutdown(void);
void stats_global(ice_config_t *config);
stats_t *stats_get_stats(void);
void stats_get_streamlist (char *buffer, size_t remaining);
refbuf_t *stats_get_streams (void);
void stats_clear_virtual_mounts (void);
void stats_event(const char *source, const char *name, const char *value);