mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-01-03 14:56:34 -05:00
merge extra checks. minor cleanup work
svn path=/icecast/trunk/icecast/; revision=9711
This commit is contained in:
parent
e2e35fe59d
commit
33cf86f527
@ -40,7 +40,7 @@ typedef struct auth_tag
|
||||
source_t *source, char *username, char *password);
|
||||
void (*free)(struct auth_tag *self);
|
||||
void *state;
|
||||
void *type;
|
||||
char *type;
|
||||
} auth_t;
|
||||
|
||||
auth_result auth_check_client(source_t *source, client_t *client);
|
||||
|
@ -768,6 +768,8 @@ static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node,
|
||||
}
|
||||
}
|
||||
|
||||
if (listener == NULL)
|
||||
return;
|
||||
do {
|
||||
if (node == NULL) break;
|
||||
if (xmlIsBlankNode(node)) continue;
|
||||
|
@ -898,7 +898,7 @@ static void _handle_get_request (client_t *client, char *passed_uri)
|
||||
|
||||
client->write_to_client = format_generic_write_to_client;
|
||||
client->check_buffer = format_check_http_buffer;
|
||||
client->refbuf = refbuf_new (4096);
|
||||
client->refbuf = refbuf_new (PER_CLIENT_REFBUF_SIZE);
|
||||
|
||||
avl_tree_wlock(source->pending_tree);
|
||||
avl_insert(source->pending_tree, (void *)client);
|
||||
|
@ -156,7 +156,7 @@ int format_check_file_buffer (source_t *source, client_t *client)
|
||||
return -1;
|
||||
}
|
||||
/* source -> file fallback, need a refbuf for data */
|
||||
refbuf = refbuf_new (4096);
|
||||
refbuf = refbuf_new (PER_CLIENT_REFBUF_SIZE);
|
||||
client->refbuf = refbuf;
|
||||
client->pos = refbuf->len;
|
||||
client->intro_offset = 0;
|
||||
|
@ -150,6 +150,7 @@ static void free_ogg_codecs (ogg_state_t *ogg_info)
|
||||
ogg_info->codecs = NULL;
|
||||
ogg_info->current = NULL;
|
||||
ogg_info->bos_completed = 0;
|
||||
ogg_info->codec_count = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -211,6 +212,12 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
|
||||
}
|
||||
do
|
||||
{
|
||||
if (ogg_info->codec_count > 10)
|
||||
{
|
||||
ERROR0 ("many codecs in stream, playing safe, dropping source");
|
||||
ogg_info->error = 1;
|
||||
return -1;
|
||||
}
|
||||
codec = initial_vorbis_page (plugin, page);
|
||||
if (codec)
|
||||
break;
|
||||
@ -241,6 +248,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
|
||||
/* add codec to list */
|
||||
codec->next = ogg_info->codecs;
|
||||
ogg_info->codecs = codec;
|
||||
ogg_info->codec_count++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -374,14 +382,14 @@ static refbuf_t *ogg_get_buffer (source_t *source)
|
||||
ogg_state_t *ogg_info = source->format->_state;
|
||||
format_plugin_t *format = source->format;
|
||||
char *data = NULL;
|
||||
int bytes;
|
||||
int bytes = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
ogg_page page;
|
||||
refbuf_t *refbuf;
|
||||
refbuf_t *refbuf = NULL;
|
||||
ogg_codec_t *codec = ogg_info->current;
|
||||
|
||||
/* if a codec has just been given a page then process it */
|
||||
@ -399,10 +407,12 @@ static refbuf_t *ogg_get_buffer (source_t *source)
|
||||
if (ogg_page_bos (&page))
|
||||
{
|
||||
process_initial_page (source->format, &page);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
ogg_info->bos_completed = 1;
|
||||
refbuf = process_ogg_page (ogg_info, &page);
|
||||
}
|
||||
if (ogg_info->error)
|
||||
{
|
||||
ERROR0 ("Problem processing stream");
|
||||
@ -420,7 +430,7 @@ static refbuf_t *ogg_get_buffer (source_t *source)
|
||||
data = ogg_sync_buffer (&ogg_info->oy, 4096);
|
||||
|
||||
bytes = client_read_bytes (source->client, data, 4096);
|
||||
if (bytes < 0)
|
||||
if (bytes <= 0)
|
||||
{
|
||||
ogg_sync_wrote (&ogg_info->oy, 0);
|
||||
return NULL;
|
||||
|
@ -28,6 +28,7 @@ typedef struct ogg_state_tag
|
||||
ogg_sync_state oy;
|
||||
int error;
|
||||
|
||||
int codec_count;
|
||||
struct ogg_codec_tag *codecs;
|
||||
char *artist;
|
||||
char *title;
|
||||
|
@ -36,5 +36,7 @@ refbuf_t *refbuf_new(unsigned long size);
|
||||
void refbuf_addref(refbuf_t *self);
|
||||
void refbuf_release(refbuf_t *self);
|
||||
|
||||
#define PER_CLIENT_REFBUF_SIZE 4096
|
||||
|
||||
#endif /* __REFBUF_H__ */
|
||||
|
||||
|
10
src/source.c
10
src/source.c
@ -610,8 +610,11 @@ static void source_init (source_t *source)
|
||||
source->running = 1;
|
||||
|
||||
mountinfo = config_find_mount (config_get_config(), source->mount);
|
||||
if (mountinfo && mountinfo->on_connect)
|
||||
if (mountinfo)
|
||||
{
|
||||
if (mountinfo->on_connect)
|
||||
source_run_script (mountinfo->on_connect, source->mount);
|
||||
}
|
||||
config_release_config();
|
||||
|
||||
/*
|
||||
@ -810,8 +813,11 @@ static void source_shutdown (source_t *source)
|
||||
INFO1("Source \"%s\" exiting", source->mount);
|
||||
|
||||
mountinfo = config_find_mount (config_get_config(), source->mount);
|
||||
if (mountinfo && mountinfo->on_disconnect)
|
||||
if (mountinfo)
|
||||
{
|
||||
if (mountinfo->on_disconnect)
|
||||
source_run_script (mountinfo->on_disconnect, source->mount);
|
||||
}
|
||||
config_release_config();
|
||||
|
||||
/* we have de-activated the source now, so no more clients will be
|
||||
|
Loading…
Reference in New Issue
Block a user