mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-06-30 22:18:19 -04: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:
parent
2822e350bb
commit
cbb7643b43
13
src/admin.c
13
src/admin.c
@ -995,17 +995,12 @@ static void command_list_mounts(client_t *client, int response)
|
|||||||
|
|
||||||
if (response == PLAINTEXT)
|
if (response == PLAINTEXT)
|
||||||
{
|
{
|
||||||
char *buf;
|
snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
|
||||||
int remaining = PER_CLIENT_REFBUF_SIZE;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
buf = client->refbuf->data;
|
|
||||||
ret = snprintf (buf, remaining,
|
|
||||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n");
|
"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->refbuf->len = strlen (client->refbuf->data);
|
||||||
|
client->respcode = 200;
|
||||||
|
|
||||||
|
client->refbuf->next = stats_get_streams ();
|
||||||
fserve_add_client (client, NULL);
|
fserve_add_client (client, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -261,6 +261,8 @@ static void *fserv_thread_function(void *arg)
|
|||||||
else
|
else
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
if (bytes == 0)
|
if (bytes == 0)
|
||||||
|
{
|
||||||
|
if (refbuf->next == NULL)
|
||||||
{
|
{
|
||||||
fserve_t *to_go = fclient;
|
fserve_t *to_go = fclient;
|
||||||
fclient = fclient->next;
|
fclient = fclient->next;
|
||||||
@ -270,6 +272,10 @@ static void *fserv_thread_function(void *arg)
|
|||||||
client_tree_changed = 1;
|
client_tree_changed = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
client_set_queue (client, refbuf->next);
|
||||||
|
refbuf = client->refbuf;
|
||||||
|
bytes = refbuf->len;
|
||||||
|
}
|
||||||
refbuf->len = (unsigned int)bytes;
|
refbuf->len = (unsigned int)bytes;
|
||||||
client->pos = 0;
|
client->pos = 0;
|
||||||
}
|
}
|
||||||
|
21
src/stats.c
21
src/stats.c
@ -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 */
|
refbuf_t *stats_get_streams (void)
|
||||||
void stats_get_streamlist (char *buffer, size_t remaining)
|
|
||||||
{
|
{
|
||||||
|
#define STREAMLIST_BLKSIZE 4096
|
||||||
avl_node *node;
|
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 */
|
/* now the stats for each source */
|
||||||
thread_mutex_lock (&_stats_mutex);
|
thread_mutex_lock (&_stats_mutex);
|
||||||
@ -1111,10 +1114,13 @@ void stats_get_streamlist (char *buffer, size_t remaining)
|
|||||||
|
|
||||||
if (source->hidden == 0)
|
if (source->hidden == 0)
|
||||||
{
|
{
|
||||||
if (remaining <= strlen (source->source)+2)
|
if (remaining <= strlen (source->source) + 3)
|
||||||
{
|
{
|
||||||
WARN0 ("streamlist was truncated");
|
cur->len = STREAMLIST_BLKSIZE - remaining;
|
||||||
break;
|
cur->next = refbuf_new (STREAMLIST_BLKSIZE);
|
||||||
|
remaining = STREAMLIST_BLKSIZE;
|
||||||
|
cur = cur->next;
|
||||||
|
buffer = cur->data;
|
||||||
}
|
}
|
||||||
ret = snprintf (buffer, remaining, "%s\r\n", source->source);
|
ret = snprintf (buffer, remaining, "%s\r\n", source->source);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
@ -1123,12 +1129,15 @@ void stats_get_streamlist (char *buffer, size_t remaining)
|
|||||||
remaining -= ret;
|
remaining -= ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node = avl_get_next(node);
|
node = avl_get_next(node);
|
||||||
}
|
}
|
||||||
thread_mutex_unlock (&_stats_mutex);
|
thread_mutex_unlock (&_stats_mutex);
|
||||||
|
cur->len = STREAMLIST_BLKSIZE - remaining;
|
||||||
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This removes any source stats from virtual mountpoints, ie mountpoints
|
/* This removes any source stats from virtual mountpoints, ie mountpoints
|
||||||
* where no source_t exists. This function requires the global sources lock
|
* where no source_t exists. This function requires the global sources lock
|
||||||
* to be held before calling.
|
* to be held before calling.
|
||||||
|
@ -76,7 +76,7 @@ void stats_shutdown(void);
|
|||||||
|
|
||||||
void stats_global(ice_config_t *config);
|
void stats_global(ice_config_t *config);
|
||||||
stats_t *stats_get_stats(void);
|
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_clear_virtual_mounts (void);
|
||||||
|
|
||||||
void stats_event(const char *source, const char *name, const char *value);
|
void stats_event(const char *source, const char *name, const char *value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user